blib/lib/Patch/rand/Secure.pm

filter: Statementstmt 57.1% 12 / 21 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 3 / 6 Podpod n/a totaltotal 55.5% 15 / 27 CC 1 SCAR 4.1
CC
1
Cov
57%
import
2.0
unimport
2.0
__ANON__
2.0
CRAP 1.5
↑ Summary
1 package Patch::rand::Secure;
2  
3 1 our $DATE = '2018-01-02'; # DATE
4 1 our $VERSION = '0.001'; # VERSION
5  
6 1 ▶use strict 'subs', 'vars';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Math::Random::Secure;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 0 ▶sub import {
Subroutine import: not called CC=1 SCAR=6.9
11 0 my $pkg = shift;
12  
13 0 my $caller = caller();
14 0 *{"$caller\::rand"} = \&Math::Random::Secure::rand;
15 }
16  
17 0 ▶sub unimport {
Subroutine unimport: not called CC=1 SCAR=6.9
18 0 my $pkg = shift;
19  
20 0 my $caller = caller();
21 # XXX find a better way to restore original rand
22 0 ▶ *{"$caller\::rand"} = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
23 0 CORE::rand(@_);
24 0 };
25 }
26  
27 1 1;
28 # ABSTRACT: Replace rand() with Math::Random::Secure's version
29  
30 __END__
↑ Summary