| 1 | package Devel::XSCover::DB; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 33 | ▶ | use 5.020; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 33 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 33 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 33 | ▶ | use Cwd (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 33 | ▶ | use File::Path (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 33 | ▶ | use File::Spec (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 33 | ▶ | use Devel::XSCover::Flow (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 33 | our $VERSION = '0.08'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 33 | our (@CRITERIA); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 33 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 33 | @CRITERIA = qw(statement branch subroutine); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 33 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 33 | my ($class, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 33 | my $self = bless { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | dir => '.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | db => 'cover_db', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | dry => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | silent => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 33 | $self->{$_} = $args{$_} for keys %args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 33 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 32 | ▶ | sub merge { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 32 | my ($self, @objects) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 32 | my (%files, %generated); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 32 | for my $object (@objects) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 45 | ▶ | _merge_into(\%files, $object->{files} || {}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$object->{'files'} || {}
MC/DC100%1/1
$object->{'files'} || {}
$object->{'files'}
Truth table100%2/2
A
A= $object->{'files'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 45 | ▶ | _merge_into(\%generated, $object->{generated} || {}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$object->{'generated'} || {}
MC/DC100%1/1
$object->{'generated'} || {}
$object->{'generated'}
Truth table100%2/2
A
A= $object->{'generated'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 32 | return (\%files, \%generated); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 90 | ▶ | sub _merge_into { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_merge_into: called CC=26 SCAR=32.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 90 | my ($into, $from) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 90 | for my $name (sort keys %$from) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 85 | my $src = $from->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 85 | ▶ | my $dst = $into->{$name} //= { lines => {}, functions => [], blocks => [], conditions => [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$into->{$name} //= {"lines", {}, "functions", [], "blocks", [], "conditions", []}
MC/DC100%1/1
$into->{$name} //= {"lines", {}, "functions", [], "blocks", [], "conditions", []}
$into->{$name}
Truth table100%2/2
A
A= $into->{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 85 | $dst->{lines}{$_} += $src->{lines}{$_} for keys %{ $src->{lines} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 85 | my %fn = map { ("$_->{name}\0$_->{line}", $_) } @{ $dst->{functions} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 85 | for my $f (@{ $src->{functions} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 193 | my $key = "$f->{name}\0$f->{line}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 193 | ▶ | if ($fn{$key}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 11 | $fn{$key}{count} += $f->{count}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 182 | push @{ $dst->{functions} }, $fn{$key} = { %$f }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 85 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | my %have; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 85 | for my $b (@{ $dst->{blocks} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 15 | push @{ $have{ $b->{line} } }, $b; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 85 | for my $b (@{ $src->{blocks} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 470 | my $n = $seen{ $b->{line} }++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 470 | my $peer = $have{ $b->{line} }[$n]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 470 | ▶ | if ($peer && @{ $peer->{arms} } == @{ $b->{arms} }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$peer and @{$peer->{"arms"};} == @{$b->{"arms"};}
MC/DC100%2/2
$peer and @{$peer->{"arms"};} == @{$b->{"arms"};}
$peer
@{$peer->{"arms"};} == @{$b->{"arms"};}
Truth table100%3/3
A and B
A= $peerB= @{$peer->{"arms"};} == @{$b->{"arms"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 14 | $peer->{arms}[$_] += $b->{arms}[$_] for 0 .. $#{ $b->{arms} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 456 | my $copy = { line => $b->{line}, arms => [ @{ $b->{arms} } ] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 456 | push @{ $dst->{blocks} }, $copy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 456 | push @{ $have{ $b->{line} } }, $copy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 85 | ▶ | if ($src->{decisions}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 4 | my (%dseen, %dhave); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 4 | ▶ | $dst->{decisions} //= []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$dst->{"decisions"} //= []
MC/DC100%1/1
$dst->{"decisions"} //= []
$dst->{"decisions"}
Truth table100%2/2
A
A= $dst->{"decisions"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 4 | push @{ $dhave{ $_->{line} } }, $_ for @{ $dst->{decisions} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 4 | for my $d (@{ $src->{decisions} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 6 | my $n = $dseen{ $d->{line} }++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 6 | my $peer = $dhave{ $d->{line} }[$n]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 6 | ▶ | if ($peer && @{ $peer->{arms} } == @{ $d->{arms} }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$peer and @{$peer->{"arms"};} == @{$d->{"arms"};}
MC/DC100%2/2
$peer and @{$peer->{"arms"};} == @{$d->{"arms"};}
$peer
@{$peer->{"arms"};} == @{$d->{"arms"};}
Truth table100%3/3
A and B
A= $peerB= @{$peer->{"arms"};} == @{$d->{"arms"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 1 | $peer->{arms}[$_] += $d->{arms}[$_] for 0 .. $#{ $d->{arms} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 5 | my $copy = { line => $d->{line}, arms => [ @{ $d->{arms} } ] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 5 | push @{ $dst->{decisions} }, $copy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 5 | push @{ $dhave{ $d->{line} } }, $copy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 85 | my (%cseen, %chave); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 85 | push @{ $chave{ $_->{line} } }, $_ for @{ $dst->{conditions} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 85 | ▶ | for my $d (@{ $src->{conditions} || [] }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$src->{'conditions'} || []
MC/DC100%1/1
$src->{'conditions'} || []
$src->{'conditions'}
Truth table100%2/2
A
A= $src->{'conditions'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 9 | my $n = $cseen{ $d->{line} }++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 9 | my $peer = $chave{ $d->{line} }[$n]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 9 | ▶ | if ($peer && @{ $peer->{terms} } == @{ $d->{terms} }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$peer and @{$peer->{"terms"};} == @{$d->{"terms"};}
MC/DC100%2/2
$peer and @{$peer->{"terms"};} == @{$d->{"terms"};}
$peer
@{$peer->{"terms"};} == @{$d->{"terms"};}
Truth table100%3/3
A and B
A= $peerB= @{$peer->{"terms"};} == @{$d->{"terms"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 1 | for my $k (0 .. $#{ $d->{terms} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 3 | ▶ | $peer->{terms}[$k]{$_} ||= $d->{terms}[$k]{$_} for qw(true false); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$peer->{"terms"}[$k]{$_} ||= $d->{"terms"}[$k]{$_}
MC/DC100%2/2
$peer->{"terms"}[$k]{$_} ||= $d->{"terms"}[$k]{$_}
$peer->{"terms"}[$k]{$_}
$d->{"terms"}[$k]{$_}
Truth table100%3/3
A ||= B
A= $peer->{"terms"}[$k]{$_}B= $d->{"terms"}[$k]{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 8 | my $copy = { line => $d->{line}, covered => $d->{covered}, total => $d->{total}, terms => [ map { { %$_ } } @{ $d->{terms} } ] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 8 | push @{ $dst->{conditions} }, $copy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 8 | push @{ $chave{ $d->{line} } }, $copy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 37 | ▶ | sub entries { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
entries: called CC=35 SCAR=35.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 37 | my ($self, $files, $generated, @maps) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 37 | my %out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 37 | for my $map (@maps) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 15 | ▶ | my $inverse = $map->{inverse} or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 12 | for my $file (keys %$inverse) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 1 | ▶ | $self->_relocate($files->{$file}, $inverse->{$file}) if $files->{$file}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 37 | for my $file (sort keys %$files) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 58 | my $f = $files->{$file}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 58 | my $e = $out{$file} = { statement => [], branch => [], subroutine => [], condition => [] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 58 | for my $line (sort { $a <=> $b } keys %{ $f->{lines} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 513 | ▶ | next if $self->_braces_only($file, $line); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 489 | push @{ $e->{statement} }, [ $line, $f->{lines}{$line} ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | my @branches = $f->{decisions} && !$self->{macro_branches} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 3 | ? @{ $f->{decisions} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 58 | ▶ | : grep { @{ $_->{arms} } >= 2 && ($self->{macro_branches} || $self->_decides($file, $_->{line})) } @{ $f->{blocks} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
$f->{"decisions"} and not $self->{"macro_branches"}
@{$_->{'arms'};} >= 2 && ($self->{'macro_branches'} || $self->_decides($file, $_->{'line'}))
$self->{"macro_branches"} or $self->_decides($file, $_->{"line"})
MC/DC100%2/2
$f->{"decisions"} and not $self->{"macro_branches"}
$f->{"decisions"}
not $self->{"macro_branches"}
MC/DC100%3/3
@{$_->{'arms'};} >= 2 && ($self->{'macro_branches'} || $self->_decides($file, $_->{'line'}))
@{$_->{'arms'};} >= 2
$self->{"macro_branches"}
$self->_decides($file, $_->{"line"})
Truth table100%3/3
A and not(B)
A= $f->{"decisions"}B= not $self->{"macro_branches"}
Truth table100%4/4
A && B or C
A= @{$_->{'arms'};} >= 2B= $self->{"macro_branches"}C= $self->_decides($file, $_->{"line"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 58 | for my $b (sort { $a->{line} <=> $b->{line} } @branches) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 108 | my @arms = @{ $b->{arms} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 108 | ▶ | if (@arms == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 86 | push @{ $e->{branch} }, [ $b->{line}, $self->_source_text($file, $b->{line}), [@arms] ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 86 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 22 | my $total = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 22 | $total += $_ for @arms; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 22 | for my $k (0 .. $#arms) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 98 | push @{ $e->{branch} }, [ $b->{line}, sprintf('arm %d of %d', $k + 1, scalar @arms), [ $arms[$k], $total - $arms[$k] ] ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 58 | ▶ | for my $d (sort { $a->{line} <=> $b->{line} } @{ $f->{conditions} || [] }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$f->{'conditions'} || []
MC/DC100%1/1
$f->{'conditions'} || []
$f->{'conditions'}
Truth table100%2/2
A
A= $f->{'conditions'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 15 | ▶ | next unless $self->{macro_branches} || $self->_terms($file, $d->{line}) == @{ $d->{terms} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"macro_branches"} or $self->_terms($file, $d->{"line"}) == @{$d->{"terms"};}
MC/DC100%2/2
$self->{"macro_branches"} or $self->_terms($file, $d->{"line"}) == @{$d->{"terms"};}
$self->{"macro_branches"}
$self->_terms($file, $d->{"line"}) == @{$d->{"terms"};}
Truth table100%3/3
A or B
A= $self->{"macro_branches"}B= $self->_terms($file, $d->{"line"}) == @{$d->{"terms"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 11 | my $text = $self->_source_text($file, $d->{line}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 11 | for my $k (0 .. $#{ $d->{terms} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 19 | my $term = $d->{terms}[$k]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 19 | ▶ | push @{ $e->{condition} }, [ $d->{line}, { type => 'and_2', left => 'term ' . ($k + 1), op => 'of', right => $text }, [ $term->{true} ? 1 : 0, $term->{false} ? 1 : 0 ] ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 58 | for my $fn (sort { $a->{line} <=> $b->{line} } sort { $a->{name} cmp $b->{name} } @{ $f->{functions} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 45 | push @{ $e->{subroutine} }, [ $fn->{line}, $fn->{name}, $fn->{count} ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 37 | for my $map (@maps) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 15 | ▶ | my %count = map { $_->{name} => $_->{count} } @{ $generated->{ $map->{c} }{functions} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$$generated{$map->{'c'}}{'functions'} || []
MC/DC100%1/1
$$generated{$map->{'c'}}{'functions'} || []
$$generated{$map->{'c'}}{'functions'}
Truth table100%2/2
A
A= $$generated{$map->{'c'}}{'functions'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 15 | for my $c_name (sort keys %{ $map->{xsubs} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 128 | my $x = $map->{xsubs}{$c_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 128 | ▶ | next unless defined $x->{line} && @{ $x->{names} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $x->{"line"} and @{$x->{"names"};}
MC/DC100%2/2
defined $x->{"line"} and @{$x->{"names"};}
defined $x->{"line"}
@{$x->{"names"};}
Truth table100%3/3
A and B
A= defined $x->{"line"}B= @{$x->{"names"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 126 | ▶ | next if %count && !exists $count{$c_name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
%count and not exists $count{$c_name}
MC/DC100%2/2
%count and not exists $count{$c_name}
%count
not exists $count{$c_name}
Truth table100%3/3
A and not(B)
A= %countB= not exists $count{$c_name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 125 | ▶ | my $e = $out{ $x->{file} } //= { statement => [], branch => [], subroutine => [], condition => [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$out{$x->{"file"}} //= {"statement", [], "branch", [], "subroutine", [], "condition", []}
MC/DC100%1/1
$out{$x->{"file"}} //= {"statement", [], "branch", [], "subroutine", [], "condition", []}
$out{$x->{"file"}}
Truth table100%2/2
A
A= $out{$x->{"file"}}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 125 | for my $name (@{ $x->{names} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 136 | ▶ | push @{ $e->{subroutine} }, [ $x->{line}, $name, $count{$c_name} // 0 ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$count{$c_name} // 0
MC/DC100%1/1
$count{$c_name} // 0
$count{$c_name}
Truth table100%2/2
A
A= $count{$c_name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 37 | for my $e (values %out) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 61 | @{ $e->{subroutine} } = sort { $a->[0] <=> $b->[0] } sort { $a->[1] cmp $b->[1] } @{ $e->{subroutine} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 37 | return \%out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 16 | ▶ | sub write { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write: called CC=14 SCAR=26.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 16 | my ($self, $entries) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 16 | require Devel::Cover::DB; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 16 | require Devel::Cover::DB::Structure; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 16 | my $here = Cwd::getcwd(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 16 | ▶ | chdir $self->{dir} or die "xs_cover: cannot chdir to $self->{dir}: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 15 | my $db = File::Spec->rel2abs($self->{db}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 15 | ▶ | my @criteria = (@CRITERIA, (grep { @{ $_->{condition} || [] } } values %$entries) ? ('condition') : ()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$_->{'condition'} || []
MC/DC100%1/1
$_->{'condition'} || []
$_->{'condition'}
Truth table100%2/2
A
A= $_->{'condition'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 15 | my %run = (collected => [@criteria], start => time, run => "xs_cover $self->{dir}", perl => sprintf('%vd', $^V), OS => $^O); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 15 | my $structure = Devel::Cover::DB::Structure->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 15 | $structure->add_criteria(@criteria); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 15 | my %summary = (files => 0, statement => 0, branch => 0, subroutine => 0, condition => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 15 | for my $file (sort keys %$entries) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 48 | my $e = $entries->{$file}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 48 | ▶ | unless (-f $file) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 1 | warn "xs_cover: no source $file under $self->{dir}, skipped\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 47 | $run{digests}{$file} = $structure->set_file($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 47 | $summary{files}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 47 | for my $s (@{ $e->{statement} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 455 | $structure->add_statement($file, $s->[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 455 | push @{ $run{count}{$file}{statement} }, $s->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 455 | $summary{statement}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 47 | for my $b (@{ $e->{branch} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 159 | $structure->add_branch($file, [ $b->[0], { text => $b->[1] } ]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 159 | push @{ $run{count}{$file}{branch} }, [ @{ $b->[2] } ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 159 | $summary{branch}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 47 | for my $s (@{ $e->{subroutine} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 176 | $structure->add_subroutine($file, [ $s->[0], $s->[1] ]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 176 | push @{ $run{count}{$file}{subroutine} }, $s->[2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 176 | $summary{subroutine}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 47 | ▶ | for my $c (@{ $e->{condition} || [] }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$e->{'condition'} || []
MC/DC100%1/1
$e->{'condition'} || []
$e->{'condition'}
Truth table100%2/2
A
A= $e->{'condition'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 8 | $structure->add_condition($file, [ $c->[0], $c->[1] ]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 8 | push @{ $run{count}{$file}{condition} }, [ @{ $c->[2] } ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 8 | $summary{condition}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 15 | $run{finish} = time; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 15 | my $name = $run{start} . ".$$." . sprintf '%05d', rand 2**16; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 15 | my $path = File::Spec->catdir($db, 'runs', $name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | $self->_say(sprintf 'xs_cover: writing %d file%s, %d statements, %d branches, %d subroutines%s to %s', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 15 | ▶ | $summary{files}, $summary{files} == 1 ? '' : 's', @summary{qw(statement branch subroutine)}, $summary{condition} ? ", $summary{condition} conditions" : '', $path); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 15 | ▶ | unless ($self->{dry}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 14 | my $cover = Devel::Cover::DB->new(base => $db, runs => { $name => \%run }, structure => $structure); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 14 | File::Path::make_path(File::Spec->catdir($db, 'runs')); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 14 | $cover->{db} = $path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 14 | $cover->write; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 15 | chdir $here; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 15 | return { run => $path, %summary }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 1 | ▶ | sub _relocate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_relocate: called CC=7 SCAR=19.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 1 | my ($self, $f, $to) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 1 | my %lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 1 | ▶ | $lines{ $to->{$_} // $_ } += $f->{lines}{$_} for keys %{ $f->{lines} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$to->{$_} // $_
MC/DC0%0/2
$to->{$_} // $_
$to->{$_}
$_
Truth table33%1/3
A // B
A= $to->{$_}B= $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 1 | $f->{lines} = \%lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 1 | for my $list (qw(functions blocks conditions decisions)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 4 | ▶ | $_->{line} = $to->{ $_->{line} } // $_->{line} for @{ $f->{$list} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition80%4/5
$f->{$list} || []
$$to{$_->{"line"}} // $_->{"line"}
MC/DC100%1/1
$f->{$list} || []
$f->{$list}
MC/DC0%0/2
$$to{$_->{"line"}} // $_->{"line"}
$$to{$_->{"line"}}
$_->{"line"}
Truth table100%2/2
A
A= $f->{$list}
Truth table66%2/3
A // B
A= $$to{$_->{"line"}}B= $_->{"line"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 97 | ▶ | sub _decides { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_decides: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 97 | my ($self, $file, $line) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 97 | my $text = $self->_source_text($file, $line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 97 | $text =~ s{/\*.*?\*/}{ }g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 97 | $text =~ s{//.*}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 97 | ▶ | return $text =~ /\b(?:if|else|while|for|do|switch)\b|\?|&&|\|\|/ ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 513 | ▶ | sub _braces_only { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_braces_only: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 513 | my ($self, $file, $line) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 513 | my $src = $self->_clean_source($file)->{lines}[$line - 1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 513 | ▶ | return defined $src && $src =~ /\}/ && $src =~ /^[\s{}]*(?:else[\s{}]*)?$/ ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
defined $src and $src =~ /\}/u and $src =~ /^[\s{}]*(?:else[\s{}]*)?$/u
defined $src and $src =~ /\}/u
MC/DC100%3/3
defined $src and $src =~ /\}/u and $src =~ /^[\s{}]*(?:else[\s{}]*)?$/u
defined $src
$src =~ /\}/u
$src =~ /^[\s{}]*(?:else[\s{}]*)?$/u
Truth table100%4/4
A and B and C
A= defined $srcB= $src =~ /\}/uC= $src =~ /^[\s{}]*(?:else[\s{}]*)?$/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 11 | ▶ | sub _terms { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_terms: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 11 | my ($self, $file, $line) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 11 | my $clean = $self->_clean_source($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 11 | my ($from, $to) = ($line, $line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 11 | for my $r (@{ $clean->{ranges} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 12 | ▶ | next unless $r->{line} <= $line && $line <= $r->{end}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$r->{"line"} <= $line and $line <= $r->{"end"}
MC/DC100%2/2
$r->{"line"} <= $line and $line <= $r->{"end"}
$r->{"line"} <= $line
$line <= $r->{"end"}
Truth table100%3/3
A and B
A= $r->{"line"} <= $lineB= $line <= $r->{"end"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 5 | ($from, $to) = ($r->{line}, $r->{end}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 5 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 11 | ▶ | my $text = join ' ', map { $clean->{lines}[$_ - 1] // '' } $from .. $to; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$clean->{"lines"}[$_ - 1] // ""
MC/DC100%1/1
$clean->{"lines"}[$_ - 1] // ""
$clean->{"lines"}[$_ - 1]
Truth table100%2/2
A
A= $clean->{"lines"}[$_ - 1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 11 | my $ops = () = $text =~ /&&|\|\|/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 11 | ▶ | return $ops + 1 if $ops || $from < $to || $text =~ /\b(?:if|while|for|switch)\s*\(|\?/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$ops or $from < $to or $text =~ /\b(?:if|while|for|switch)\s*\(|\?/u
$ops or $from < $to
MC/DC100%3/3
$ops or $from < $to or $text =~ /\b(?:if|while|for|switch)\s*\(|\?/u
$ops
$from < $to
$text =~ /\b(?:if|while|for|switch)\s*\(|\?/u
Truth table100%4/4
A or B or C
A= $opsB= $from < $toC= $text =~ /\b(?:if|while|for|switch)\s*\(|\?/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 3 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 524 | ▶ | sub _clean_source { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_clean_source: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 524 | my ($self, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 524 | ▶ | return $self->{clean}{$file} if $self->{clean}{$file}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 52 | my $flow = Devel::XSCover::Flow->new(dir => $self->{dir}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 52 | my @raw = map { "$_\n" } @{ $self->_source_lines($file) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 52 | return $self->{clean}{$file} = { lines => [ $flow->clean(\@raw) ], ranges => [ $flow->ranges(\@raw) ] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 246 | ▶ | sub _source_lines { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_source_lines: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 246 | my ($self, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 246 | ▶ | return $self->{source}{$file} if $self->{source}{$file}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 53 | my $path = File::Spec->catfile($self->{dir}, $file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 53 | my @l; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 53 | ▶ | if (open my $fh, '<', $path) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 52 | @l = <$fh>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 52 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 52 | chomp @l; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 53 | return $self->{source}{$file} = \@l; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 194 | ▶ | sub _source_text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_source_text: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 194 | my ($self, $file, $line) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 194 | ▶ | my $text = $self->_source_lines($file)->[ $line - 1 ] // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->_source_lines($file)->[$line - 1] // ""
MC/DC100%1/1
$self->_source_lines($file)->[$line - 1] // ""
$self->_source_lines($file)->[$line - 1]
Truth table100%2/2
A
A= $self->_source_lines($file)->[$line - 1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 194 | $text =~ s/^\s+|\s+$//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 194 | $text =~ s/\s+/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 194 | return $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 15 | ▶ | sub _say { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_say: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 15 | my ($self, $line) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 15 | ▶ | print "$line\n" unless $self->{silent}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 33 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||