Tangerine/hook/if.pm

filter: Statementstmt 100% 39 / 39 Branchbran 85.7% 12 / 14 Conditioncond 55.1% 16 / 29 MC/DCmcdc 28.5% 4 / 14 Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 76.4% 81 / 106 CC 18 SCAR 27.9
CC
18
Cov
82%
run
23.1
BEGIN
1.0
BEGIN
1.0
CRAP 16.3
« Tangerine.pm ↑ Summary Tangerine/hook/testrequires.pm »
1 package Tangerine::hook::if;
2 15 $Tangerine::hook::if::VERSION = '0.21';
3 15 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 15 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 15 ▶use parent 'Tangerine::Hook';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 15 ▶use List::Util 1.33 qw(any);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 15 ▶use Tangerine::HookData;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 15 ▶use Tangerine::Utils qw(stripquotelike $vre);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 sub run {
13 136 ▶ my ($self, $s) = @_;
Subroutine run: called CC=18 SCAR=31.4
Pod documented
14 136 ▶ if ((any { $s->[0] eq $_ } qw(use no)) &&
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if (&any(sub { $s->[0] eq $_; } , "use", "no") and scalar @$s > 3 and $s->[1] eq "if") 5 131 136
Condition100%6/6
&any(sub { $s->[0] eq $_; } , "use", "no") and scalar @$s > 3 and $s->[1] eq "if"
!ll&&!rl&&r
83485
&any(sub { $s->[0] eq $_; } , "use", "no") and scalar @$s > 3
!ll&&!rl&&r
552853
MC/DC100%3/3
&any(sub { $s->[0] eq $_; } , "use", "no") and scalar @$s > 3 and $s->[1] eq "if"
&any(sub { $s->[0] eq $_; } , "use", "no") scalar @$s > 3 $s->[1] eq "if"
Truth table100%4/4
A and B and C
A= &any(sub { $s->[0] eq $_; } , "use", "no")B= scalar @$s > 3C= $s->[1] eq "if"
ABCresult
0XX0
10X0
1100
1111
15 scalar(@$s) > 3 && $s->[1] eq 'if') {
16 5 my ($version) = $s->[2] =~ $vre;
17 5 ▶ $version //= '';
Condition100%2/2
$version //= ""
l!l
14
MC/DC100%1/1
$version //= ""
$version
Truth table100%2/2
A
A= $version
Aresult
11
00
18 5 ▶ my $voffset = $version ? 3 : 2;
Branch: 1 branch
BranchTrueFalseTotal
$version ? : 1 4 5
19 5 my ($depth, $index) = (0, 0);
20 5 ▶ for ($index = $voffset; $index < $#$s; $index++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($index < $s->$#*) 11 1 12
21 11 my $token = $s->[$index];
22 11 ▶ $depth++ if ($token eq '[' || $token eq '{' || $token eq '(');
Branch: 1 branch
BranchTrueFalseTotal
if $token eq "[" or $token eq "{" or $token eq "(" 0 11 11
Condition33%2/6
$token eq "[" or $token eq "{" or $token eq "("
l!l&&r!l&&!r
0011
$token eq "[" or $token eq "{"
l!l&&r!l&&!r
0011
MC/DC0%0/3
$token eq "[" or $token eq "{" or $token eq "("
$token eq "[" $token eq "{" $token eq "("
Truth table25%1/4
A or B or C
A= $token eq "["B= $token eq "{"C= $token eq "("
ABCresult
1XX1
01X1
0011
0000
23 11 ▶ $depth-- if ($token eq ']' || $token eq '}' || $token eq ')');
Branch: 1 branch
BranchTrueFalseTotal
if $token eq "]" or $token eq "}" or $token eq ")" 0 11 11
Condition33%2/6
$token eq "]" or $token eq "}" or $token eq ")"
l!l&&r!l&&!r
0011
$token eq "]" or $token eq "}"
l!l&&r!l&&!r
0011
MC/DC0%0/3
$token eq "]" or $token eq "}" or $token eq ")"
$token eq "]" $token eq "}" $token eq ")"
Truth table25%1/4
A or B or C
A= $token eq "]"B= $token eq "}"C= $token eq ")"
ABCresult
1XX1
01X1
0011
0000
24 11 ▶ last if ($token eq ';' || !$depth &&
Branch: 1 branch
BranchTrueFalseTotal
if $token eq ";" or not $depth and $token eq "," || $token eq "=>" 4 7 11
Condition44%4/9
$token eq ";" or not $depth and $token eq "," || $token eq "=>"
l!l&&r!l&&!r
0011
not $depth and $token eq "," || $token eq "=>"
!ll&&!rl&&r
0110
$token eq "," or $token eq "=>"
l!l&&r!l&&!r
407
MC/DC0%0/4
$token eq ";" or not $depth and $token eq "," || $token eq "=>"
$token eq ";" not $depth $token eq "," $token eq "=>"
Truth table20%1/5
A or not(B) and C or D
A= $token eq ";"B= not $depthC= $token eq ","D= $token eq "=>"
ABCDresult
1XXX1
011X1
01011
00XX0
01000
25 ($token eq ',' || $token eq '=>'));
26 }
27 5 $index++;
28 5 ▶ if ($s->[$index]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s->[$index]) 4 1 5
29 4 $s->[$index] = stripquotelike($s->[$index]);
30 4 return Tangerine::HookData->new(
31 children => [ $s->[0], @$s[$index..$#$s] ],
32 );
33 }
34 }
35 132 return;
36 }
37  
38 15 1;
39  
40 __END__
« Tangerine.pm ↑ Summary Tangerine/hook/testrequires.pm »