Product/PP.pm

filter: Statementstmt 100% 36 / 36 Branchbran 91.6% 11 / 12 Conditioncond 85.7% 6 / 7 MC/DCmcdc 75.0% 3 / 4 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 95.4% 63 / 66 CC 10 SCAR 19.5
CC
10
Cov
96%
product
10.0
BEGIN
1.0
BEGIN
1.0
CRAP 7.0
↑ Summary Product.pm »
1 package Set::Product::PP;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use Scalar::Util qw(reftype);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 4 our @EXPORT_OK = qw(product);
11  
12 sub product (&@) {
13 8 ▶ my ($sub, @in) = @_;
Subroutine product: called CC=10 SCAR=23.0
Pod documented
14  
15 8 ▶ croak 'Not a subroutine reference'
Branch: 1 branch
BranchTrueFalseTotal
unless "CODE" eq (builtin::reftype($sub) || "") 0 8 8
Condition50%1/2
builtin::reftype($sub) || ''
l!l
80
MC/DC0%0/1
builtin::reftype($sub) || ''
builtin::reftype($sub)
Truth table50%1/2
A
A= builtin::reftype($sub)
Aresult
11
00
16 unless 'CODE' eq (reftype($sub) || '');
17 croak 'Not an array reference'
18 8 ▶ if grep { 'ARRAY' ne (reftype($_) || '') } @in;
Branch: 1 branch
BranchTrueFalseTotal
if grep {"ARRAY" ne (builtin::reftype($_) || "");} @in 1 7 8
Condition100%2/2
builtin::reftype($_) || ''
l!l
153
MC/DC100%1/1
builtin::reftype($_) || ''
builtin::reftype($_)
Truth table100%2/2
A
A= builtin::reftype($_)
Aresult
11
00
19 7 ▶ return if ! @in or grep { ! @$_ } @in;
Branch: 1 branch
BranchTrueFalseTotal
if not @in or grep {not @$_;} @in 2 5 7
Condition100%3/3
not @in or grep {not @$_;} @in
l!l&&r!l&&!r
115
MC/DC100%2/2
not @in or grep {not @$_;} @in
not @in grep {not @$_;} @in
Truth table100%3/3
not(A) or B
A= not @inB= grep {not @$_;} @in
ABresult
1X1
011
000
20  
21 5 my @out = map { $in[$_]->[0] } 0 .. $#in;
22 5 my @idx = (0) x @in;
23  
24 5 ▶ for (my $i = 0; $i >= 0; ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i >= 0) 22 5 27
25 22 $sub->(@out);
26 22 ▶ for ($i=$#in; $i >= 0; $i--) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i >= 0) 32 5 37
27 32 $idx[$i]++;
28 32 ▶ if ($idx[$i] > $#{$in[$i]}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($idx[$i] > $#{$in[$i];}) { } 15 17 32
29 15 $idx[$i] = 0;
30 15 $out[$i] = $in[$i]->[0];
31 }
32 else {
33 17 $out[$i] = $in[$i]->[$idx[$i]];
34 17 last;
35 }
36 }
37 }
38 }
39  
40  
41 4 1;
42  
43 __END__
↑ Summary Product.pm »