blib/lib/Math/SimpleHisto/XS/RNG.pm

filter: Statementstmt 100% 29 / 29 Branchbran 75.0% 6 / 8 Conditioncond 50.0% 2 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 2 totaltotal 82.3% 42 / 51 CC 8 SCAR 11.8
CC
8
Cov
90%
rand
5.2
_seed
3.0
new
2.0
CRAP 3.2
« blib/lib/Math/SimpleHisto/XS.pm ↑ Summary blib/lib/Math/SimpleHisto/XS/Named.pm »
1 package Math::SimpleHisto::XS::RNG;
2 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 11 our $VERSION = '0.01';
6  
7 11 our $Gen = __PACKAGE__->new(_seed());
8  
9 11 ▶sub _seed {
Subroutine _seed: called CC=3 SCAR=11.0
10 11 my $x;
11 11 ▶ my @refs = (\$x, [], {}, sub {}); # yeah, random is different :(
Subroutine __ANON__: not called CC=1 SCAR=0.0
12 11 my @ints = (time, $$);
13 11 foreach my $ref (@refs) {
14 44 $ref = "$ref";
15 44 ▶ $ref =~ s/^\w+\(0x(\w+)\)$/$1/ or next;
Branch: 1 branch
BranchTrueFalseTotal
$ref =~ s/^\w+\(0x(\w+)\)$/$1/ or next 44 0 44
16 44 $ref = unpack("h*", $ref);
17 44 $ref = $ref % 2**31;
18 44 push @ints, $ref;
19 }
20 11 return @ints;
21 }
22  
23  
24 14 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod undocumented
25 14 my $class = shift;
26 14 ▶ if (@_ == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) { } 3 11 14
27 3 return setup(shift); # XS
28 }
29 else {
30 11 return setup_array(@_); # XS
31 }
32 }
33  
34 2 ▶sub rand {
Subroutine rand: called CC=5 SCAR=16.6
Pod undocumented
35 2 my ($self, $x) = @_;
36 2 ▶ if (ref $self) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self) { } 1 1 2
37 1 ▶ return ($x || 1) * $self->genrand();
Condition50%1/2
$x || 1
l!l
01
MC/DC0%0/1
$x || 1
$x
Truth table50%1/2
A
A= $x
Aresult
11
00
38 }
39 else {
40 1 $x = $self;
41 1 ▶ $Gen = __PACKAGE__->new(_seed()) if not defined $Gen;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $Math::SimpleHisto::XS::RNG::Gen 0 1 1
42 1 ▶ return ($x || 1) * $Gen->genrand();
Condition50%1/2
$x || 1
l!l
10
MC/DC0%0/1
$x || 1
$x
Truth table50%1/2
A
A= $x
Aresult
11
00
43 }
44 }
45  
46 11 1;
« blib/lib/Math/SimpleHisto/XS.pm ↑ Summary blib/lib/Math/SimpleHisto/XS/Named.pm »