Random/Provider/rand.pm

filter: Statementstmt 94.4% 34 / 36 Branchbran 75.0% 6 / 8 Conditioncond 58.8% 10 / 17 MC/DCmcdc 10.0% 1 / 10 Subroutinesub 88.8% 8 / 9 Podpod 0.0% 0 / 3 totaltotal 71.0% 59 / 83 CC 11 SCAR 18.7
CC
11
Cov
82%
get_data
11.2
new
2.1
__ANON__
1.2
CRAP 6.5
« Random/Provider/File.pm ↑ Summary Random.pm »
1 ##
2 ## Copyright (c) 1998-2025, Vipul Ved Prakash. All rights reserved.
3 ## This code is free software; you can redistribute it and/or modify
4 ## it under the same terms as Perl itself.
5  
6 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 package Crypt::Random::Provider::rand;
9 3 ▶use Math::Pari qw(pari2num);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use Crypt::URandom qw/urandom/;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 3 our $VERSION = '1.57';
13  
14 13 ▶sub new {
Subroutine new: called CC=2 SCAR=7.4
Pod undocumented
15  
16 13 my ($class, %params) = @_;
17 13 ▶ my $self = { Source => $params{Source} || sub { Crypt::URandom::urandom($_[0]) } };
Subroutine __ANON__: called CC=1 SCAR=0.6
Condition33%1/3
$params{'Source'} || sub { Crypt::URandom::urandom($_[0]); }
l!l&&r!l&&!r
0130
MC/DC0%0/2
$params{'Source'} || sub { Crypt::URandom::urandom($_[0]); }
$params{'Source'} sub { Crypt::URandom::urandom($_[0]); }
Truth table33%1/3
A || B
A= $params{'Source'}B= sub { Crypt::URandom::urandom($_[0]); }
ABresult
1X1
011
000
18 13 return bless $self, $class;
19  
20 }
21  
22 13 ▶sub get_data {
Subroutine get_data: called CC=10 SCAR=24.2
Pod undocumented
23  
24 13 my ($self, %params) = @_;
25 13 ▶ $self = {} unless ref $self;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 13 13
26  
27 13 my $size = $params{Size};
28 13 ▶ my $skip = $params{Skip} || $$self{Skip} || '';
Condition80%4/5
$params{'Skip'} || $self->{'Skip'} || ''
l!l
112
$params{"Skip"} or $self->{"Skip"}
l!l&&r!l&&!r
1012
MC/DC50%1/2
$params{'Skip'} || $self->{'Skip'} || ''
$params{"Skip"} $self->{"Skip"}
Truth table66%2/3
A or B
A= $params{"Skip"}B= $self->{"Skip"}
ABresult
1X1
011
000
29 13 my $q_skip = quotemeta($skip);
30  
31 13 ▶ if ($size && ref $size eq "Math::Pari") {
Branch: 1 branch
BranchTrueFalseTotal
if ($size and ref $size eq "Math::Pari") 0 13 13
Condition66%2/3
$size and ref $size eq "Math::Pari"
!ll&&!rl&&r
3100
MC/DC0%0/2
$size and ref $size eq "Math::Pari"
$size ref $size eq "Math::Pari"
Truth table66%2/3
A and B
A= $sizeB= ref $size eq "Math::Pari"
ABresult
0X0
100
111
32 0 $size = pari2num($size);
33 }
34  
35 13 ▶ my $bytes = $params{Length} || (int($size / 8) + 1);
Condition66%2/3
$params{'Length'} || int($size / 8) + 1
l!l&&r!l&&!r
3100
MC/DC0%0/2
$params{'Length'} || int($size / 8) + 1
$params{'Length'} int($size / 8) + 1
Truth table66%2/3
A || B
A= $params{'Length'}B= int($size / 8) + 1
ABresult
1X1
011
000
36  
37 0 ▶ my $source = $$self{Source} || sub { Crypt::URandom::urandom($_[0]) };
Subroutine __ANON__: not called CC=1 SCAR=2.0
Condition33%1/3
$self->{'Source'} || sub { Crypt::URandom::urandom($_[0]); }
l!l&&r!l&&!r
1300
MC/DC0%0/2
$self->{'Source'} || sub { Crypt::URandom::urandom($_[0]); }
$self->{'Source'} sub { Crypt::URandom::urandom($_[0]); }
Truth table33%1/3
A || B
A= $self->{'Source'}B= sub { Crypt::URandom::urandom($_[0]); }
ABresult
1X1
011
000
38
39 13 my($r, $read, $rt) = ('', 0);
40 13 ▶ while ($read < $bytes) {
Branch: 1 branch
BranchTrueFalseTotal
if ($read < $bytes) 58 13 71
41 58 $rt = &$source($bytes - $read);
42 58 ▶ $rt =~ s/[$q_skip]//g if $skip;
Branch: 1 branch
BranchTrueFalseTotal
if $skip 46 12 58
43 58 $r .= $rt;
44 58 $read = length $r;
45 }
46  
47 13 $r;
48  
49 }
50  
51  
52 5 ▶sub available {
Subroutine available: called CC=1 SCAR=0.0
Pod undocumented
53  
54 5 return 1;
55  
56 }
57  
58  
59 3 1;
60
« Random/Provider/File.pm ↑ Summary Random.pm »