Tangerine/hook/testrequires.pm

filter: Statementstmt 100% 46 / 46 Branchbran 72.2% 13 / 18 Conditioncond 78.2% 18 / 23 MC/DCmcdc 58.3% 7 / 12 Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 86.2% 94 / 109 CC 18 SCAR 26.1
CC
18
Cov
89%
run
19.2
BEGIN
1.0
BEGIN
1.0
CRAP 13.6
« Tangerine/hook/if.pm ↑ Summary Tangerine/hook/list.pm »
1 package Tangerine::hook::testrequires;
2 15 $Tangerine::hook::testrequires::VERSION = '0.22';
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 Tangerine::HookData;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 15 ▶use Tangerine::Occurence;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 15 ▶use Tangerine::Utils qw(any stripquotelike $vre);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 sub run {
12 138 ▶ my ($self, $s) = @_;
Subroutine run: called CC=18 SCAR=29.5
Pod documented
13 138 my %found;
14 138 ▶ if ($self->type eq 'compile' &&
Branch: 2 branches
BranchTrueFalseTotal
if ($self->type eq 'compile' and &any(sub { $s->[0] eq $_; } , 'use', 'no') and scalar @$s > 2 and $s->[1] eq 'Test::Requires') { } 3 135 138
elsif ($self->type eq 'runtime' and $s->[0] eq 'test_requires' and scalar @$s > 1) { } 2 133 135
Condition100%9/9
$self->type eq "compile" and &any(sub { $s->[0] eq $_; } , "use", "no") and scalar @$s > 2 and $s->[1] eq "Test::Requires"
!ll&&!rl&&r
64713
$self->type eq "compile" and &any(sub { $s->[0] eq $_; } , "use", "no") and scalar @$s > 2
!ll&&!rl&&r
60474
$self->type eq "compile" and &any(sub { $s->[0] eq $_; } , "use", "no")
!ll&&!rl&&r
55578
MC/DC100%4/4
$self->type eq "compile" and &any(sub { $s->[0] eq $_; } , "use", "no") and scalar @$s > 2 and $s->[1] eq "Test::Requires"
$self->type eq "compile" &any(sub { $s->[0] eq $_; } , "use", "no") scalar @$s > 2 $s->[1] eq "Test::Requires"
Truth table100%5/5
A and B and C and D
A= $self->type eq "compile"B= &any(sub { $s->[0] eq $_; } , "use", "no")C= scalar @$s > 2D= $s->[1] eq "Test::Requires"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
15 188 ▶ (any { $s->[0] eq $_ } qw(use no)) && scalar(@$s) > 2 &&
Subroutine __ANON__: called CC=1 SCAR=0.0
16 $s->[1] eq 'Test::Requires') {
17 3 my ($version) = $s->[2] =~ $vre;
18 3 ▶ $version //= '';
Condition50%1/2
$version //= ""
l!l
03
MC/DC0%0/1
$version //= ""
$version
Truth table50%1/2
A
A= $version
Aresult
11
00
19 3 ▶ return if !$version && stripquotelike($s->[2]) =~ /^v?5(?:\..*)?$/;
Branch: 1 branch
BranchTrueFalseTotal
if not $version and stripquotelike($s->[2]) =~ /^v?5(?:\..*)?$/ 0 3 3
Condition33%1/3
not $version and stripquotelike($s->[2]) =~ /^v?5(?:\..*)?$/
!ll&&!rl&&r
030
MC/DC0%0/2
not $version and stripquotelike($s->[2]) =~ /^v?5(?:\..*)?$/
not $version stripquotelike($s->[2]) =~ /^v?5(?:\..*)?$/
Truth table33%1/3
not(A) and B
A= not $versionB= stripquotelike($s->[2]) =~ /^v?5(?:\..*)?$/
ABresult
0X0
100
111
20 3 ▶ my $voffset = $version ? 3 : 2;
Branch: 1 branch
BranchTrueFalseTotal
$version ? : 0 3 3
21 3 my @args;
22 3 ▶ if (scalar(@$s) > $voffset) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @$s > $voffset) 3 0 3
23 3 ▶ return if $s->[$voffset] eq ';';
Branch: 1 branch
BranchTrueFalseTotal
if $s->[$voffset] eq ";" 0 3 3
24 3 @args = @$s;
25 3 @args = @args[($voffset) .. $#args];
26 3 @args = stripquotelike(@args);
27 }
28 3 ▶ if (substr($s->[$voffset], 0, 1) eq '{') {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($s->[$voffset], 0, 1) eq '{') { } 1 2 3
29 1 %found = @args;
30 } else {
31 2 %found = map { $_ => '' } @args;
32 }
33 ▶ } elsif ($self->type eq 'runtime' &&
Condition83%5/6
$self->type eq "runtime" and $s->[0] eq "test_requires" and scalar @$s > 1
!ll&&!rl&&r
13302
$self->type eq "runtime" and $s->[0] eq "test_requires"
!ll&&!rl&&r
13032
MC/DC66%2/3
$self->type eq "runtime" and $s->[0] eq "test_requires" and scalar @$s > 1
$self->type eq "runtime" $s->[0] eq "test_requires" scalar @$s > 1
Truth table75%3/4
A and B and C
A= $self->type eq "runtime"B= $s->[0] eq "test_requires"C= scalar @$s > 1
ABCresult
0XX0
10X0
1100
1111
34 $s->[0] eq 'test_requires' && scalar(@$s) > 1) {
35 2 ▶ return if $s->[1] eq ';';
Branch: 1 branch
BranchTrueFalseTotal
if $s->[1] eq ";" 0 2 2
36 2 my @args = stripquotelike((@$s)[1..$#$s]);
37 2 ▶ $found{$args[0]} = $args[1] && $args[1] ne ';' ? $args[1] : '';
Branch: 1 branch
BranchTrueFalseTotal
$args[1] && $args[1] ne ';' ? : 1 1 2
Condition66%2/3
$args[1] and $args[1] ne ";"
!ll&&!rl&&r
101
MC/DC50%1/2
$args[1] and $args[1] ne ";"
$args[1] $args[1] ne ";"
Truth table66%2/3
A and B
A= $args[1]B= $args[1] ne ";"
ABresult
0X0
100
111
38 } else {
39 return
40 133 }
41 return Tangerine::HookData->new(
42 modules => {
43 map {
44 5 ( $_ => Tangerine::Occurence->new(version => $found{$_}) )
45 } keys %found,
46 },
47 )
48 }
49  
50 15 1;
51  
52 __END__
« Tangerine/hook/if.pm ↑ Summary Tangerine/hook/list.pm »