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 SCAR 23.0
CC
10
Cov
96%
product
10.0
BEGIN
1.0
BEGIN
1.0
CRAP 10.0
↑ Summary Product.pm »
1 package Set::Product::PP;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Scalar::Util qw(reftype);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 our @EXPORT_OK = qw(product);
11  
12 sub product (&@) {
13 6 ▶ my ($sub, @in) = @_;
Subroutine product: called CC=10 SCAR=23.0
Pod documented
14  
15 6 ▶ croak 'Not a subroutine reference'
Branch: 1 branch
BranchTrueFalseTotal
unless "CODE" eq (builtin::reftype($sub) || "") 0 6 6
Condition50%1/2
builtin::reftype($sub) || ''
l!l
60
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 6 ▶ if grep { 'ARRAY' ne (reftype($_) || '') } @in;
Branch: 1 branch
BranchTrueFalseTotal
if grep {"ARRAY" ne (builtin::reftype($_) || "");} @in 1 5 6
Condition100%2/2
builtin::reftype($_) || ''
l!l
113
MC/DC100%1/1
builtin::reftype($_) || ''
builtin::reftype($_)
Truth table100%2/2
A
A= builtin::reftype($_)
Aresult
11
00
19 5 ▶ return if ! @in or grep { ! @$_ } @in;
Branch: 1 branch
BranchTrueFalseTotal
if not @in or grep {not @$_;} @in 2 3 5
Condition100%3/3
not @in or grep {not @$_;} @in
l!l&&r!l&&!r
113
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 3 my @out = map { $in[$_]->[0] } 0 .. $#in;
22 3 my @idx = (0) x @in;
23  
24 3 ▶ for (my $i = 0; $i >= 0; ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i >= 0) 10 3 13
25 10 $sub->(@out);
26 10 ▶ for ($i=$#in; $i >= 0; $i--) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i >= 0) 16 3 19
27 16 $idx[$i]++;
28 16 ▶ if ($idx[$i] > $#{$in[$i]}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($idx[$i] > $#{$in[$i];}) { } 9 7 16
29 9 $idx[$i] = 0;
30 9 $out[$i] = $in[$i]->[0];
31 }
32 else {
33 7 $out[$i] = $in[$i]->[$idx[$i]];
34 7 last;
35 }
36 }
37 }
38 }
39  
40  
41 3 1;
42  
43 __END__
↑ Summary Product.pm »