Tangerine/hook/testrequires.pm

filter: Statementstmt 100% 49 / 49 Branchbran 72.2% 13 / 18 Conditioncond 78.2% 18 / 23 MC/DCmcdc 58.3% 7 / 12 Subroutinesub 100% 10 / 10 Podpod 100% 1 / 1 totaltotal 86.7% 98 / 113 CC 18 SCAR 25.7
CC
18
Cov
89%
run
19.2
BEGIN
1.0
BEGIN
1.0
CRAP 13.1
« Tangerine/hook/if.pm ↑ Summary Tangerine/hook/list.pm »
1 package Tangerine::hook::testrequires;
2 15 $Tangerine::hook::testrequires::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::Occurence;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 15 ▶use Tangerine::Utils qw(stripquotelike $vre);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 sub run {
13 137 ▶ my ($self, $s) = @_;
Subroutine run: called CC=18 SCAR=29.5
Pod documented
14 137 my %found;
15 137 ▶ 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 134 137
elsif ($self->type eq 'runtime' and $s->[0] eq 'test_requires' and scalar @$s > 1) { } 2 132 134
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
64703
$self->type eq "compile" and &any(sub { $s->[0] eq $_; } , "use", "no") and scalar @$s > 2
!ll&&!rl&&r
60473
$self->type eq "compile" and &any(sub { $s->[0] eq $_; } , "use", "no")
!ll&&!rl&&r
55577
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
16 187 ▶ (any { $s->[0] eq $_ } qw(use no)) && scalar(@$s) > 2 &&
Subroutine __ANON__: called CC=1 SCAR=0.0
17 $s->[1] eq 'Test::Requires') {
18 3 my ($version) = $s->[2] =~ $vre;
19 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
20 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
21 3 ▶ my $voffset = $version ? 3 : 2;
Branch: 1 branch
BranchTrueFalseTotal
$version ? : 0 3 3
22 3 my @args;
23 3 ▶ if (scalar(@$s) > $voffset) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @$s > $voffset) 3 0 3
24 3 ▶ return if $s->[$voffset] eq ';';
Branch: 1 branch
BranchTrueFalseTotal
if $s->[$voffset] eq ";" 0 3 3
25 3 @args = @$s;
26 3 @args = @args[($voffset) .. $#args];
27 3 @args = stripquotelike(@args);
28 }
29 3 ▶ if (substr($s->[$voffset], 0, 1) eq '{') {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($s->[$voffset], 0, 1) eq '{') { } 1 2 3
30 1 %found = @args;
31 } else {
32 2 %found = map { $_ => '' } @args;
33 }
34 ▶ } 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
13202
$self->type eq "runtime" and $s->[0] eq "test_requires"
!ll&&!rl&&r
12932
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
35 $s->[0] eq 'test_requires' && scalar(@$s) > 1) {
36 2 ▶ return if $s->[1] eq ';';
Branch: 1 branch
BranchTrueFalseTotal
if $s->[1] eq ";" 0 2 2
37 2 my @args = stripquotelike((@$s)[1..$#$s]);
38 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
39 } else {
40 return
41 132 }
42 return Tangerine::HookData->new(
43 modules => {
44 map {
45 5 ( $_ => Tangerine::Occurence->new(version => $found{$_}) )
46 } keys %found,
47 },
48 )
49 }
50  
51 15 1;
52  
53 __END__
« Tangerine/hook/if.pm ↑ Summary Tangerine/hook/list.pm »