blib/lib/Math/Partition/Rand.pm

filter: Statementstmt 100% 24 / 24 Branchbran 100% 2 / 2 Conditioncond 50.0% 2 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 4 / 4 Podpod 100% 2 / 2 totaltotal 89.4% 34 / 38 CC 5 SCAR 9.3
CC
5
Cov
93%
new
3.1
choose
3.0
BEGIN
1.0
CRAP 2.5
↑ Summary
1 package Math::Partition::Rand;
2 2 our $AUTHORITY = 'cpan:GENE';
3  
4 # ABSTRACT: Random floating point additive partitions
5  
6 2 our $VERSION = '0.0302';
7  
8 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12  
13 2 ▶sub new {
Subroutine new: called CC=3 SCAR=11.3
Pod documented
14 2 my $class = shift;
15 2 my %args = @_;
16 my $self = {
17 top => $args{top} || 1,
18 2 ▶ n => $args{n} || 2,
Condition50%2/4
$args{'top'} || 1
l!l
20
$args{'n'} || 2
l!l
20
MC/DC0%0/1
$args{'top'} || 1
$args{'top'}
MC/DC0%0/1
$args{'n'} || 2
$args{'n'}
Truth table50%1/2
A
A= $args{'top'}
Aresult
11
00
Truth table50%1/2
A
A= $args{'n'}
Aresult
11
00
19 };
20 2 bless $self, $class;
21 2 return $self;
22 }
23  
24  
25 2 ▶sub choose {
Subroutine choose: called CC=3 SCAR=11.0
Pod documented
26 2 my $self = shift;
27  
28 2 my @distribution;
29  
30 2 my $top = $self->{top};
31 2 my $n = $self->{n};
32  
33 2 for my $i ( 1 .. $n ) {
34 7 my $curr = rand($top);
35 7 my $next = abs( $top - $curr );
36  
37 7 ▶ push @distribution, $i == $n ? $top : $next;
Branch: 1 branch
BranchTrueFalseTotal
$i == $n ? : 2 5 7
38  
39 7 $top = $curr;
40 }
41  
42 2 return \@distribution;
43 }
44  
45 2 1;
46  
47 __END__
↑ Summary