| 1 | package Devel::XSCover::Flow; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 55 | ▶ | use 5.020; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 55 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 55 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 55 | ▶ | use File::Spec (); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 55 | our $VERSION = '0.10'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 55 | our ($DECISION, $DIRECTIVE); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 55 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 55 | $DECISION = qr/\b(?:if|while|for|switch)\s*\(/; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 55 | $DIRECTIVE = qr/^\s*#\s*(?:if|ifdef|ifndef|elif|else|endif|define|undef|include|line|pragma|error|warning)\b/; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 96 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 96 | my ($class, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 96 | my $self = bless { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | dir => '.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | silent => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 96 | $self->{$_} = $args{$_} for keys %args; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 96 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 12 | ▶ | sub parse_llvm { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_llvm: called CC=15 SCAR=27.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 12 | my ($self, $text, $files, $xsubs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 12 | my (@functions, $fn, $block); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 12 | for my $line (split /\n/, $text) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 4191 | ▶ | if ($line =~ /^===== (.*) \((\d+)\) @ (.*):(\d+)\s*$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 97 | $fn = { name => $1, ident => $2, file => $3, line => $4, blocks => {} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 97 | push @functions, $fn; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 97 | $block = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 97 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 4094 | ▶ | next unless $fn; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 4093 | ▶ | if ($line =~ /^Block : (\d+) Counter : (\d+)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1044 | $block = $fn->{blocks}{$1} = { id => $1, count => $2, succ => [], lines => {} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 1044 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 3049 | ▶ | next unless $block; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 3048 | ▶ | if ($line =~ /^\s*Destination Edges : (.*)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 1044 | my $edges = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1044 | ▶ | push @{ $block->{succ} }, [ $1, $2 ] while $edges =~ /\*?(\d+) \((\d+)\)/g; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 1044 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 2004 | ▶ | if ($line =~ /^\s*File: (\d+): (.*)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 965 | push @{ $block->{lines}{$1} }, grep { length } split /,/, $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 965 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 12 | my %name = $self->_llvm_files(\@functions, $files, $xsubs); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 12 | my %flow = (complete => 1, files => {}); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 12 | for my $f (@functions) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 97 | for my $b (values %{ $f->{blocks} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 1044 | my $key = "$f->{ident}:$b->{id}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 1044 | my @arcs = map { [ $key, "$f->{ident}:$_->[0]", $_->[1] ] } @{ $b->{succ} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 1044 | for my $index (keys %{ $b->{lines} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 925 | ▶ | my $file = $name{$index} // next; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$name{$index} // (next)
MC/DC100%1/1
$name{$index} // (next)
$name{$index}
Truth table100%2/2
A
A= $name{$index}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 917 | for my $n (@{ $b->{lines}{$index} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 1348 | ▶ | my $l = $flow{files}{$file}{$n} //= { blocks => {}, arcs => [], count => undef }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$flow{"files"}{$file}{$n} //= {"blocks", {}, "arcs", [], "count", undef}
MC/DC100%1/1
$flow{"files"}{$file}{$n} //= {"blocks", {}, "arcs", [], "count", undef}
$flow{"files"}{$file}{$n}
Truth table100%2/2
A
A= $flow{"files"}{$file}{$n}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 1348 | $l->{blocks}{$key} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 1348 | push @{ $l->{arcs} }, @arcs; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 12 | return \%flow; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 12 | ▶ | sub _llvm_files { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_llvm_files: called CC=33 SCAR=35.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 12 | my ($self, $functions, $files, $xsubs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 12 | my (%name, %lines, %own, %score); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 12 | for my $f (@$functions) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 97 | for my $b (values %{ $f->{blocks} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 1044 | for my $index (keys %{ $b->{lines} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 925 | $lines{$index}{$_} = 1 for @{ $b->{lines}{$index} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 925 | ▶ | $own{ $f->{ident} }{$index} = 1 if grep { $_ == $f->{line} } @{ $b->{lines}{$index} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 12 | for my $index (keys %lines) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 46 | ▶ | for my $file (keys %{ $files || {} }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$files || {}
MC/DC100%1/1
$files || {}
$files
Truth table100%2/2
A
A= $files
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 218 | ▶ | my $have = $files->{$file}{lines} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$files->{$file}{'lines'} || {}
MC/DC100%1/1
$files->{$file}{'lines'} || {}
$files->{$file}{'lines'}
Truth table100%2/2
A
A= $files->{$file}{'lines'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 218 | my $both = grep { $have->{$_} } keys %{ $lines{$index} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 218 | ▶ | next unless $both; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 78 | $score{$index}{$file} = $both / (keys(%{ $lines{$index} }) + keys(%$have) - $both); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 12 | for my $f (@$functions) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 97 | ▶ | for my $index (sort { $a <=> $b } keys %{ $own{ $f->{ident} } || {} }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$own{$f->{'ident'}} || {}
MC/DC0%0/1
$own{$f->{'ident'}} || {}
$own{$f->{'ident'}}
Truth table50%1/2
A
A= $own{$f->{'ident'}}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 98 | ▶ | next if defined $name{$index}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 38 | ▶ | if (my $sc = $score{$index}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 31 | ▶ | my $s = $sc->{ $f->{file} } // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$$sc{$f->{"file"}} // 0
MC/DC100%1/1
$$sc{$f->{"file"}} // 0
$$sc{$f->{"file"}}
Truth table100%2/2
A
A= $$sc{$f->{"file"}}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 31 | my ($top) = sort { $sc->{$b} <=> $sc->{$a} } keys %$sc; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 31 | ▶ | next unless $s >= 0.5 || $top eq $f->{file}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$s >= "0.5" or $top eq $f->{"file"}
MC/DC50%1/2
$s >= "0.5" or $top eq $f->{"file"}
$s >= "0.5"
$top eq $f->{"file"}
Truth table66%2/3
A or B
A= $s >= "0.5"B= $top eq $f->{"file"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 35 | $name{$index} = $f->{file}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 12 | for my $f (@$functions) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 97 | ▶ | my $body = $xsubs && $xsubs->{ $f->{name} } or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$xsubs && $$xsubs{$f->{'name'}}
MC/DC100%2/2
$xsubs && $$xsubs{$f->{'name'}}
$xsubs
$$xsubs{$f->{'name'}}
Truth table100%3/3
A && B
A= $xsubsB= $$xsubs{$f->{'name'}}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 2 | for my $b (values %{ $f->{blocks} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 2 | for my $index (keys %{ $b->{lines} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 4 | ▶ | $name{$index} = $body if !defined $name{$index} && !$own{ $f->{ident} }{$index}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $name{$index} or $own{$f->{"ident"}}{$index}
MC/DC50%1/2
defined $name{$index} or $own{$f->{"ident"}}{$index}
defined $name{$index}
$own{$f->{"ident"}}{$index}
Truth table66%2/3
A or B
A= defined $name{$index}B= $own{$f->{"ident"}}{$index}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 12 | my %taken = map { $_ => 1 } values %name; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 12 | for my $index (sort { $a <=> $b } keys %lines) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 46 | ▶ | next if defined $name{$index}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 9 | my ($best, $score) = (undef, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 9 | ▶ | for my $file (sort keys %{ $score{$index} || {} }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$score{$index} || {}
MC/DC100%1/1
$score{$index} || {}
$score{$index}
Truth table100%2/2
A
A= $score{$index}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 17 | ▶ | next if $taken{$file}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 10 | my $s = $score{$index}{$file}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 10 | ▶ | ($best, $score) = ($file, $s) if $s > $score; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 9 | ▶ | next unless defined $best; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 7 | $name{$index} = $best; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 7 | $taken{$best} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 12 | return %name; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 8 | ▶ | sub parse_gcc { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_gcc: called CC=14 SCAR=26.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 8 | my ($self, $json) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 8 | require JSON::PP; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 8 | my $data = JSON::PP->new->decode($json); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 8 | my %flow = (complete => 0, files => {}); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 8 | ▶ | for my $f (@{ $data->{files} || [] }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$data->{'files'} || []
MC/DC100%1/1
$data->{'files'} || []
$data->{'files'}
Truth table100%2/2
A
A= $data->{'files'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 34 | my $file = $f->{file}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 34 | ▶ | for my $l (@{ $f->{lines} || [] }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$f->{'lines'} || []
MC/DC100%1/1
$f->{'lines'} || []
$f->{'lines'}
Truth table100%2/2
A
A= $f->{'lines'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 707 | my $n = $l->{line_number}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 707 | ▶ | my $entry = $flow{files}{$file}{$n} //= { blocks => {}, arcs => [], count => undef }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$flow{"files"}{$file}{$n} //= {"blocks", {}, "arcs", [], "count", undef}
MC/DC100%1/1
$flow{"files"}{$file}{$n} //= {"blocks", {}, "arcs", [], "count", undef}
$flow{"files"}{$file}{$n}
Truth table100%2/2
A
A= $flow{"files"}{$file}{$n}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 707 | ▶ | $entry->{count} = $l->{count} if defined $l->{count}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 707 | ▶ | $entry->{blocks}{$_} = 1 for @{ $l->{block_ids} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$l->{'block_ids'} || []
MC/DC100%1/1
$l->{'block_ids'} || []
$l->{'block_ids'}
Truth table100%2/2
A
A= $l->{'block_ids'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 707 | ▶ | for my $b (@{ $l->{branches} || [] }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$l->{'branches'} || []
MC/DC100%1/1
$l->{'branches'} || []
$l->{'branches'}
Truth table100%2/2
A
A= $l->{'branches'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 470 | ▶ | next unless defined $b->{source_block_id} && defined $b->{destination_block_id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $b->{"source_block_id"} and defined $b->{"destination_block_id"}
MC/DC100%2/2
defined $b->{"source_block_id"} and defined $b->{"destination_block_id"}
defined $b->{"source_block_id"}
defined $b->{"destination_block_id"}
Truth table100%3/3
A and B
A= defined $b->{"source_block_id"}B= defined $b->{"destination_block_id"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 355 | ▶ | push @{ $entry->{arcs} }, [ $b->{source_block_id}, $b->{destination_block_id}, $b->{count} || 0 ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$b->{'count'} || 0
MC/DC100%1/1
$b->{'count'} || 0
$b->{'count'}
Truth table100%2/2
A
A= $b->{'count'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 8 | return \%flow; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 23 | ▶ | sub decisions { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decisions: called CC=10 SCAR=23.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 23 | my ($self, $flow, $inverse) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 23 | my %out; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 23 | for my $file (sort keys %{ $flow->{files} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 45 | my $lines = $flow->{files}{$file}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 45 | ▶ | my $path = File::Spec->file_name_is_absolute($file) ? $file : File::Spec->catfile($self->{dir}, $file); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 45 | ▶ | open my $fh, '<', $path or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 36 | my @src = <$fh>; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 36 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 36 | ▶ | if (my $to = $inverse && $inverse->{$file}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$inverse && $inverse->{$file}
MC/DC100%2/2
$inverse && $inverse->{$file}
$inverse
$inverse->{$file}
Truth table100%3/3
A && B
A= $inverseB= $inverse->{$file}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 1 | ▶ | @src = map { $src[ ($to->{$_} // $_) - 1 ] // "\n" } 1 .. @src; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition60%3/5
$src[($to->{$_} // $_) - 1] // "\n"
$to->{$_} // $_
MC/DC0%0/1
$src[($to->{$_} // $_) - 1] // "\n"
$src[($to->{$_} // $_) - 1]
MC/DC0%0/2
$to->{$_} // $_
$to->{$_}
$_
Truth table50%1/2
A
A= $src[($to->{$_} // $_) - 1]
Truth table66%2/3
A // B
A= $to->{$_}B= $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 36 | my @found; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 36 | for my $r ($self->ranges(\@src)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 225 | my $arms = $self->_arms($flow, $lines, $r); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 225 | ▶ | push @found, { line => $r->{line}, arms => $arms } if @$arms >= 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 36 | $out{$file} = \@found; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 23 | return \%out; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 225 | ▶ | sub _arms { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_arms: called CC=30 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 225 | my ($self, $flow, $lines, $r) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 225 | my (%member, @arcs, %seen, %succ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 225 | for my $n ($r->{line} .. $r->{end}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 236 | ▶ | my $l = $lines->{$n} or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 98 | $member{$_} = 1 for keys %{ $l->{blocks} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 98 | for my $a (@{ $l->{arcs} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 242 | ▶ | push @arcs, $a unless $seen{"$a->[0] $a->[1]"}++; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 225 | ▶ | return [] unless %member; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 80 | push @{ $succ{ $_->[0] } }, $_->[1] for @arcs; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 80 | my (%tally, %at); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 80 | my ($body, $has_body) = (0, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 80 | for my $a (@arcs) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 240 | my ($s, $d, $c) = @$a; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 240 | my $plain = @{ $succ{$s} } <= 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 240 | ▶ | if ($member{$d}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 48 | ▶ | next unless $flow->{complete} && !$plain; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$flow->{"complete"} and not $plain
MC/DC100%2/2
$flow->{"complete"} and not $plain
$flow->{"complete"}
not $plain
Truth table100%3/3
A and not(B)
A= $flow->{"complete"}B= not $plain
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 12 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 12 | ▶ | while ($member{$d} && @{ $succ{$d} || [] } <= 1 && !$seen{$d}++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%8/8
$member{$d} and @{$succ{$d} or [];} <= 1 and not $seen{$d}++
$member{$d} and @{$succ{$d} or [];} <= 1
$succ{$d} || []
MC/DC100%3/3
$member{$d} and @{$succ{$d} or [];} <= 1 and not $seen{$d}++
$member{$d}
@{$succ{$d} or [];} <= 1
not $seen{$d}++
MC/DC100%1/1
$succ{$d} || []
$succ{$d}
Truth table100%4/4
A and B and not(C)
A= $member{$d}B= @{$succ{$d} or [];} <= 1C= not $seen{$d}++
Truth table100%2/2
A
A= $succ{$d}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 6 | ▶ | last unless @{ $succ{$d} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$succ{$d} || []
MC/DC100%1/1
$succ{$d} || []
$succ{$d}
Truth table100%2/2
A
A= $succ{$d}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 5 | $d = $succ{$d}[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 12 | ▶ | next if $member{$d} && @{ $succ{$d} || [] } > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%5/5
$member{$d} and @{$succ{$d} or [];} > 1
$succ{$d} || []
MC/DC100%2/2
$member{$d} and @{$succ{$d} or [];} > 1
$member{$d}
@{$succ{$d} or [];} > 1
MC/DC100%1/1
$succ{$d} || []
$succ{$d}
Truth table100%3/3
A and B
A= $member{$d}B= @{$succ{$d} or [];} > 1
Truth table100%2/2
A
A= $succ{$d}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 5 | ▶ | if ($r->{body}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 3 | $body += $c; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 3 | $has_body = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 3 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | ▶ | elsif ($flow->{complete} && $plain) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$flow->{"complete"} and $plain
MC/DC100%2/2
$flow->{"complete"} and $plain
$flow->{"complete"}
$plain
Truth table100%3/3
A and B
A= $flow->{"complete"}B= $plain
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 4 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 190 | $tally{$d} += $c; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 190 | ($at{$d}) = $d =~ /(\d+)\z/; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 80 | my @arms = map { $tally{$_} } sort { $at{$a} <=> $at{$b} } sort keys %tally; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 80 | ▶ | if ($r->{body} && !$flow->{complete}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$r->{"body"} and not $flow->{"complete"}
MC/DC100%2/2
$r->{"body"} and not $flow->{"complete"}
$r->{"body"}
not $flow->{"complete"}
Truth table100%3/3
A and not(B)
A= $r->{"body"}B= not $flow->{"complete"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 3 | my $count = $lines->{ $r->{line} }{count}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 3 | my $seen = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 3 | $seen += $_ for @arms; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 3 | ▶ | unshift @arms, defined $count && $count > $seen ? $count - $seen : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $count and $count > $seen
MC/DC100%2/2
defined $count and $count > $seen
defined $count
$count > $seen
Truth table100%3/3
A and B
A= defined $countB= $count > $seen
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | elsif ($has_body) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 3 | unshift @arms, $body; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 80 | return \@arms; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 37 | ▶ | sub dropped { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dropped: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 37 | my ($self, $src) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 37 | my (%dropped, $in_body); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 37 | my $n = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 37 | for my $text (@$src) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 4369 | $n++; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 4369 | ▶ | $in_body = 1 if !$in_body && $text =~ /^MODULE\s*=/; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $in_body and $text =~ /^MODULE\s*=/u
MC/DC100%2/2
not $in_body and $text =~ /^MODULE\s*=/u
not $in_body
$text =~ /^MODULE\s*=/u
Truth table100%3/3
not(A) and B
A= not $in_bodyB= $text =~ /^MODULE\s*=/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 4369 | ▶ | next unless $in_body && $text =~ /^\s*#/; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$in_body and $text =~ /^\s*#/u
MC/DC100%2/2
$in_body and $text =~ /^\s*#/u
$in_body
$text =~ /^\s*#/u
Truth table100%3/3
A and B
A= $in_bodyB= $text =~ /^\s*#/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 16 | ▶ | next if $text =~ $DIRECTIVE; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 8 | $dropped{$n} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 37 | return \%dropped; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 89 | ▶ | sub ranges { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ranges: called CC=13 SCAR=25.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 89 | my ($self, $src) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 89 | my @clean = $self->clean($src); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 89 | my @ranges; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 89 | for my $i (0 .. $#clean) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 4498 | my $t = $clean[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 4498 | ▶ | next unless $t =~ $DECISION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 329 | my $pos = $+[0] - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 329 | my ($depth, $j, $rest) = (0, $i, undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 329 | ▶ | LINE: while ($j <= $#clean) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 343 | my $s = $clean[$j]; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 343 | ▶ | for (my $k = $j == $i ? $pos : 0; $k < length $s; $k++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 2520 | my $c = substr $s, $k, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 2520 | ▶ | if ($c eq '(') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 352 | $depth++; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | ▶ | elsif ($c eq ')' && !--$depth) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$c eq ")" and not --$depth
MC/DC100%2/2
$c eq ")" and not --$depth
$c eq ")"
not --$depth
Truth table100%3/3
A and not(B)
A= $c eq ")"B= not --$depth
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 317 | $rest = substr $s, $k + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 317 | last LINE; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 26 | $j++; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 329 | ▶ | next unless defined $rest; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 317 | $rest =~ s/^\s+|\s+$//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 317 | ▶ | push @ranges, { line => $i + 1, end => $j + 1, body => length $rest && $rest ne '{' && $rest ne ';' ? 1 : 0 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
length $rest and $rest ne "{" and $rest ne ";"
length $rest and $rest ne "{"
MC/DC100%3/3
length $rest and $rest ne "{" and $rest ne ";"
length $rest
$rest ne "{"
$rest ne ";"
Truth table100%4/4
A and B and C
A= length $restB= $rest ne "{"C= $rest ne ";"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 89 | return @ranges; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 142 | ▶ | sub clean { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clean: called CC=19 SCAR=29.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 142 | my ($self, $src) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 142 | my ($comment, $directive) = (0, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 142 | my @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 142 | for my $line (@$src) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 6437 | my $s = $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 6437 | chomp $s; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 6437 | my $o = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 6437 | ▶ | if ($directive) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 22 | ▶ | $directive = $s =~ /\\\z/ ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 22 | push @out, ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 22 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 6415 | ▶ | if (!$comment && $s =~ /^\s*#/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $comment and $s =~ /^\s*#/u
MC/DC100%2/2
not $comment and $s =~ /^\s*#/u
not $comment
$s =~ /^\s*#/u
Truth table100%3/3
not(A) and B
A= not $commentB= $s =~ /^\s*#/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 684 | ▶ | $directive = $s =~ /\\\z/ ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 684 | push @out, ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 684 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 5731 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 5731 | ▶ | while ($i < length $s) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 67761 | ▶ | if ($comment) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 228 | my $end = index $s, '*/', $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 228 | ▶ | if ($end < 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 82 | $i = length $s; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 146 | $i = $end + 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 146 | $comment = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 228 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 67533 | my $c = substr $s, $i, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 67533 | ▶ | if ($c eq '/' && substr($s, $i + 1, 1) eq '*') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$c eq "/" and substr($s, $i + 1, 1) eq "*"
MC/DC100%2/2
$c eq "/" and substr($s, $i + 1, 1) eq "*"
$c eq "/"
substr($s, $i + 1, 1) eq "*"
Truth table100%3/3
A and B
A= $c eq "/"B= substr($s, $i + 1, 1) eq "*"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 146 | $comment = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 146 | $i += 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 146 | $o .= ' '; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 146 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 67387 | ▶ | if ($c eq '/' && substr($s, $i + 1, 1) eq '/') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$c eq "/" and substr($s, $i + 1, 1) eq "/"
MC/DC100%2/2
$c eq "/" and substr($s, $i + 1, 1) eq "/"
$c eq "/"
substr($s, $i + 1, 1) eq "/"
Truth table100%3/3
A and B
A= $c eq "/"B= substr($s, $i + 1, 1) eq "/"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 13 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 67374 | ▶ | if ($c eq '"' || $c eq "'") { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$c eq "\"" or $c eq "'"
MC/DC100%2/2
$c eq "\"" or $c eq "'"
$c eq "\""
$c eq "'"
Truth table100%3/3
A or B
A= $c eq "\""B= $c eq "'"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 291 | my $j = $i + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 291 | ▶ | while ($j < length $s) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 2114 | my $d = substr $s, $j, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 2114 | ▶ | $j++ if $d eq '\\'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 2114 | $j++; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 2114 | ▶ | last if $d eq $c; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 291 | $o .= $c . $c; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 291 | $i = $j; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 291 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 67083 | $o .= $c; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 67083 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 5731 | push @out, $o; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 142 | return @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 55 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||