| 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.08'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 | 11 | ▶ | sub parse_llvm { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_llvm: called CC=15 SCAR=27.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 11 | my ($self, $text, $files, $xsubs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 11 | my (@functions, $fn, $block); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 11 | for my $line (split /\n/, $text) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 4186 | ▶ | if ($line =~ /^===== (.*) \((\d+)\) @ (.*):(\d+)\s*$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 96 | $fn = { name => $1, ident => $2, file => $3, line => $4, blocks => {} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 96 | push @functions, $fn; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 96 | $block = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 96 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 4090 | ▶ | next unless $fn; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 4089 | ▶ | if ($line =~ /^Block : (\d+) Counter : (\d+)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1043 | $block = $fn->{blocks}{$1} = { id => $1, count => $2, succ => [], lines => {} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 1043 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 3046 | ▶ | next unless $block; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 3045 | ▶ | if ($line =~ /^\s*Destination Edges : (.*)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 1043 | my $edges = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1043 | ▶ | push @{ $block->{succ} }, [ $1, $2 ] while $edges =~ /\*?(\d+) \((\d+)\)/g; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 1043 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 2002 | ▶ | if ($line =~ /^\s*File: (\d+): (.*)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 963 | push @{ $block->{lines}{$1} }, grep { length } split /,/, $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 963 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 11 | my %name = $self->_llvm_files(\@functions, $files, $xsubs); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 11 | my %flow = (complete => 1, files => {}); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 11 | for my $f (@functions) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 96 | for my $b (values %{ $f->{blocks} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 1043 | my $key = "$f->{ident}:$b->{id}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 1043 | my @arcs = map { [ $key, "$f->{ident}:$_->[0]", $_->[1] ] } @{ $b->{succ} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 1043 | for my $index (keys %{ $b->{lines} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 923 | ▶ | 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 | 919 | for my $n (@{ $b->{lines}{$index} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 1350 | ▶ | 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 | 1350 | $l->{blocks}{$key} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 1350 | push @{ $l->{arcs} }, @arcs; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 11 | return \%flow; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 11 | ▶ | sub _llvm_files { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_llvm_files: called CC=24 SCAR=31.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 11 | my ($self, $functions, $files, $xsubs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 11 | my (%name, %lines, %own); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 11 | for my $f (@$functions) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 96 | for my $b (values %{ $f->{blocks} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 1043 | for my $index (keys %{ $b->{lines} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 923 | $lines{$index}{$_} = 1 for @{ $b->{lines}{$index} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 923 | ▶ | $own{ $f->{ident} }{$index} = 1 if grep { $_ == $f->{line} } @{ $b->{lines}{$index} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 923 | ▶ | $name{$index} = $f->{file} if !defined $name{$index} && $own{ $f->{ident} }{$index}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not defined $name{$index} and $own{$f->{"ident"}}{$index}
MC/DC100%2/2
not defined $name{$index} and $own{$f->{"ident"}}{$index}
not defined $name{$index}
$own{$f->{"ident"}}{$index}
Truth table100%3/3
not(A) and B
A= not defined $name{$index}B= $own{$f->{"ident"}}{$index}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 11 | for my $f (@$functions) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 96 | ▶ | 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'}}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 2 | for my $b (values %{ $f->{blocks} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 2 | for my $index (keys %{ $b->{lines} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 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}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 11 | my %taken = map { $_ => 1 } values %name; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 11 | for my $index (sort { $a <=> $b } keys %lines) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 44 | ▶ | next if defined $name{$index}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 7 | my ($best, $score) = (undef, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 7 | ▶ | for my $file (sort keys %{ $files || {} }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$files || {}
MC/DC100%1/1
$files || {}
$files
Truth table100%2/2
A
A= $files
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 37 | ▶ | next if $taken{$file}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 14 | ▶ | 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'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 14 | my $both = grep { $have->{$_} } keys %{ $lines{$index} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 14 | ▶ | next unless $both; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 9 | my $union = keys(%{ $lines{$index} }) + keys(%$have) - $both; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 9 | my $s = $both / $union; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 9 | ▶ | ($best, $score) = ($file, $s) if $s > $score; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 7 | ▶ | next unless defined $best; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 6 | $name{$index} = $best; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 6 | $taken{$best} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 11 | return %name; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 8 | ▶ | sub parse_gcc { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_gcc: called CC=14 SCAR=26.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 8 | my ($self, $json) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 8 | require JSON::PP; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 8 | my $data = JSON::PP->new->decode($json); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 8 | my %flow = (complete => 0, files => {}); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 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'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 34 | my $file = $f->{file}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 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'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 707 | my $n = $l->{line_number}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 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}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 707 | ▶ | $entry->{count} = $l->{count} if defined $l->{count}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 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'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 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'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 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'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 8 | return \%flow; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 23 | ▶ | sub decisions { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decisions: called CC=10 SCAR=23.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 23 | my ($self, $flow, $inverse) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 23 | my %out; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 23 | for my $file (sort keys %{ $flow->{files} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 46 | my $lines = $flow->{files}{$file}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 46 | ▶ | my $path = File::Spec->file_name_is_absolute($file) ? $file : File::Spec->catfile($self->{dir}, $file); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 46 | ▶ | open my $fh, '<', $path or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 37 | my @src = <$fh>; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 37 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 37 | ▶ | 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}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 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= $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 37 | my @found; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 37 | for my $r ($self->ranges(\@src)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 226 | my $arms = $self->_arms($flow, $lines, $r); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 226 | ▶ | push @found, { line => $r->{line}, arms => $arms } if @$arms >= 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 37 | $out{$file} = \@found; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 23 | return \%out; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 226 | ▶ | sub _arms { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_arms: called CC=30 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 226 | my ($self, $flow, $lines, $r) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 226 | my (%member, @arcs, %seen, %succ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 226 | for my $n ($r->{line} .. $r->{end}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 237 | ▶ | my $l = $lines->{$n} or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 99 | $member{$_} = 1 for keys %{ $l->{blocks} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 99 | for my $a (@{ $l->{arcs} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 244 | ▶ | push @arcs, $a unless $seen{"$a->[0] $a->[1]"}++; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 226 | ▶ | return [] unless %member; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 81 | push @{ $succ{ $_->[0] } }, $_->[1] for @arcs; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 81 | my (%tally, %at); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 81 | my ($body, $has_body) = (0, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 81 | for my $a (@arcs) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 242 | my ($s, $d, $c) = @$a; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 242 | my $plain = @{ $succ{$s} } <= 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 242 | ▶ | if ($member{$d}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 12 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 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}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 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}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 5 | $d = $succ{$d}[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 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}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 5 | ▶ | if ($r->{body}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 3 | $body += $c; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 3 | $has_body = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 3 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 4 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 192 | $tally{$d} += $c; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 192 | ($at{$d}) = $d =~ /(\d+)\z/; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 81 | my @arms = map { $tally{$_} } sort { $at{$a} <=> $at{$b} } sort keys %tally; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 81 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 3 | my $count = $lines->{ $r->{line} }{count}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 3 | my $seen = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 3 | $seen += $_ for @arms; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | elsif ($has_body) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 3 | unshift @arms, $body; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 81 | return \@arms; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 37 | ▶ | sub dropped { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dropped: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 37 | my ($self, $src) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 37 | my (%dropped, $in_body); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 37 | my $n = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 37 | for my $text (@$src) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 4369 | $n++; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 16 | ▶ | next if $text =~ $DIRECTIVE; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 8 | $dropped{$n} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 37 | return \%dropped; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 90 | ▶ | sub ranges { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ranges: called CC=13 SCAR=25.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 90 | my ($self, $src) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 90 | my @clean = $self->clean($src); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 90 | my @ranges; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 90 | for my $i (0 .. $#clean) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 4516 | my $t = $clean[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 4516 | ▶ | next unless $t =~ $DECISION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 330 | my $pos = $+[0] - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 330 | my ($depth, $j, $rest) = (0, $i, undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 330 | ▶ | LINE: while ($j <= $#clean) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 344 | my $s = $clean[$j]; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 344 | ▶ | for (my $k = $j == $i ? $pos : 0; $k < length $s; $k++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 2527 | my $c = substr $s, $k, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 2527 | ▶ | if ($c eq '(') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 353 | $depth++; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 318 | $rest = substr $s, $k + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 318 | last LINE; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 26 | $j++; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 330 | ▶ | next unless defined $rest; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 318 | $rest =~ s/^\s+|\s+$//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 318 | ▶ | 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 ";"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 90 | return @ranges; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 143 | ▶ | sub clean { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clean: called CC=19 SCAR=29.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 143 | my ($self, $src) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 143 | my ($comment, $directive) = (0, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 143 | my @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 143 | for my $line (@$src) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 6455 | my $s = $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 6455 | chomp $s; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 6455 | my $o = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 6455 | ▶ | if ($directive) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 22 | ▶ | $directive = $s =~ /\\\z/ ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 22 | push @out, ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 22 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 6433 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 687 | ▶ | $directive = $s =~ /\\\z/ ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 687 | push @out, ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 687 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 5746 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 5746 | ▶ | while ($i < length $s) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 67938 | ▶ | if ($comment) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 228 | my $end = index $s, '*/', $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 228 | ▶ | if ($end < 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 82 | $i = length $s; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 146 | $i = $end + 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 146 | $comment = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 228 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 67710 | my $c = substr $s, $i, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 67710 | ▶ | 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 "*"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 146 | $comment = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 146 | $i += 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 146 | $o .= ' '; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 146 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 67564 | ▶ | 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 "/"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 13 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 67551 | ▶ | 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 "'"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 291 | my $j = $i + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 291 | ▶ | while ($j < length $s) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 2114 | my $d = substr $s, $j, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 2114 | ▶ | $j++ if $d eq '\\'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 2114 | $j++; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 2114 | ▶ | last if $d eq $c; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 291 | $o .= $c . $c; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 291 | $i = $j; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 291 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 67260 | $o .= $c; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 67260 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 5746 | push @out, $o; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 143 | return @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 55 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||