« lib/App/Test/Generator/CoverageGuidedFuzzer.pm
↑ Summary
lib/App/Test/Generator/Analyzer/Complexity.pm »
| 1 | package App::Test::Generator::Mutation::Feedback; | ||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||
| 3 | 184 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 4 | 184 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 5 | 184 | ▶ | use Carp qw(croak carp); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 6 | 184 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 7 | 184 | ▶ | use JSON::MaybeXS qw(decode_json); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||
| 9 | 184 | our $VERSION = '0.50'; | |||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||
| 11 | =head1 NAME | ||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||
| 13 | App::Test::Generator::Mutation::Feedback - Turn surviving mutants into boundary | ||||||||||||||||||||||||||||||||||
| 14 | cases and schema constraints | ||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||
| 16 | =head1 VERSION | ||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||
| 18 | Version 0.50 | ||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||
| 20 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||
| 22 | use App::Test::Generator::Mutation::Feedback; | ||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||
| 24 | my $feedback = App::Test::Generator::Mutation::Feedback->new( | ||||||||||||||||||||||||||||||||||
| 25 | mutation_results => 'mutation.json', | ||||||||||||||||||||||||||||||||||
| 26 | module => 'My::Module', | ||||||||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||
| 29 | my $applied = $feedback->apply_to_schema($schema); | ||||||||||||||||||||||||||||||||||
| 30 | printf "added %s = %s to %s\n", | ||||||||||||||||||||||||||||||||||
| 31 | $_->{constraint}, $_->{value}, $_->{field} for @{$applied}; | ||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||
| 33 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||
| 35 | A mutation survivor is a mutant the test suite did not notice. Until now a | ||||||||||||||||||||||||||||||||||
| 36 | survivor was only counted and printed; this module reads the survivors from | ||||||||||||||||||||||||||||||||||
| 37 | the JSON written by C<test-generator-mutate --json> and proposes concrete | ||||||||||||||||||||||||||||||||||
| 38 | inputs that would have killed them. | ||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||
| 40 | For a surviving numeric-boundary mutant the source line is read back and the | ||||||||||||||||||||||||||||||||||
| 41 | comparison it mutated is recovered, for example C<< $count > 10 >>. That | ||||||||||||||||||||||||||||||||||
| 42 | comparison is then translated into a schema constraint: | ||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||
| 44 | source comparison proposed constraint | ||||||||||||||||||||||||||||||||||
| 45 | $x > N min => N + 1 | ||||||||||||||||||||||||||||||||||
| 46 | $x >= N min => N | ||||||||||||||||||||||||||||||||||
| 47 | $x < N max => N - 1 | ||||||||||||||||||||||||||||||||||
| 48 | $x <= N max => N | ||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||
| 50 | Integer literals only. The constraint makes L<App::Test::Generator::Template> | ||||||||||||||||||||||||||||||||||
| 51 | generate values on both sides of the boundary, which is what the survivor | ||||||||||||||||||||||||||||||||||
| 52 | showed was missing. | ||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||
| 54 | Constraints are only applied to a field of the schema's C<input> section | ||||||||||||||||||||||||||||||||||
| 55 | whose name matches the variable in the source comparison, after normalising | ||||||||||||||||||||||||||||||||||
| 56 | case and punctuation. An existing constraint is never replaced: a bound the | ||||||||||||||||||||||||||||||||||
| 57 | POD or the code already declares wins over a proposed one. | ||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||
| 59 | Survivors that do not describe a numeric comparison - conditional inversions, | ||||||||||||||||||||||||||||||||||
| 60 | boolean negations and so on - produce a C<manual> proposal instead of an | ||||||||||||||||||||||||||||||||||
| 61 | automatic change, because no single data value is known to distinguish them. | ||||||||||||||||||||||||||||||||||
| 62 | They are still returned by L</proposals> so a reviewer can see what survived. | ||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||
| 64 | Only survivors belonging to C<module>'s own file are used when C<module> is | ||||||||||||||||||||||||||||||||||
| 65 | given, so a mutation run over a whole C<lib> directory feeds only the matching | ||||||||||||||||||||||||||||||||||
| 66 | module's schema. | ||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||
| 68 | =head2 new | ||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||
| 70 | Construct a feedback object. | ||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||
| 72 | my $feedback = App::Test::Generator::Mutation::Feedback->new( | ||||||||||||||||||||||||||||||||||
| 73 | mutation_results => 'mutation.json', | ||||||||||||||||||||||||||||||||||
| 74 | module => 'My::Module', | ||||||||||||||||||||||||||||||||||
| 75 | source_root => '.', | ||||||||||||||||||||||||||||||||||
| 76 | ); | ||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||
| 78 | =head3 Arguments | ||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||
| 80 | =over 4 | ||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||
| 82 | =item * C<mutation_results> | ||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||
| 84 | Required. Either the path to a mutation results JSON file or an already | ||||||||||||||||||||||||||||||||||
| 85 | decoded hashref with the same shape. The file must contain a C<survived> | ||||||||||||||||||||||||||||||||||
| 86 | arrayref whose entries have C<id>, C<file> and C<line> keys; entries with a | ||||||||||||||||||||||||||||||||||
| 87 | C<status> other than C<Survived> are ignored. | ||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||
| 89 | =item * C<module> | ||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||
| 91 | Optional module name, e.g. C<My::Module>. When given, only survivors whose | ||||||||||||||||||||||||||||||||||
| 92 | C<file> names that module's file (C<My/Module.pm>) are proposed, so results | ||||||||||||||||||||||||||||||||||
| 93 | from a whole-directory mutation run can be fed to one schema safely. | ||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||
| 95 | =item * C<source_root> | ||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||
| 97 | Optional directory used to resolve the relative C<file> paths in the results. | ||||||||||||||||||||||||||||||||||
| 98 | Defaults to the current directory. | ||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||
| 100 | =back | ||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||
| 102 | =head3 Returns | ||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||
| 104 | A blessed hashref. Croaks when C<mutation_results> is missing, unreadable or | ||||||||||||||||||||||||||||||||||
| 105 | not valid JSON, and when no module file can be matched but C<module> is set. | ||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||
| 107 | =head3 API SPECIFICATION | ||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||
| 109 | =head4 input | ||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||
| 111 | { | ||||||||||||||||||||||||||||||||||
| 112 | mutation_results => { type => 'any' }, | ||||||||||||||||||||||||||||||||||
| 113 | module => { type => 'string', optional => 1 }, | ||||||||||||||||||||||||||||||||||
| 114 | source_root => { type => 'string', optional => 1 }, | ||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||
| 117 | C<mutation_results> is a file name or a hashref, so no single type is | ||||||||||||||||||||||||||||||||||
| 118 | declared for it. | ||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||
| 120 | =head4 output | ||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||
| 122 | { type => OBJECT, isa => 'App::Test::Generator::Mutation::Feedback' } | ||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||
| 124 | =head2 survivors | ||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||
| 126 | Return the survivors from the results, filtered to the configured module. | ||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||
| 128 | my $survivors = $feedback->survivors; | ||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||
| 130 | =head3 Returns | ||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||
| 132 | An arrayref of survivor hashrefs, in the order they appear in the results. | ||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||
| 134 | =head3 API SPECIFICATION | ||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||
| 136 | =head4 input | ||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||
| 138 | { self => { type => OBJECT, isa => 'App::Test::Generator::Mutation::Feedback' } } | ||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||
| 140 | =head4 output | ||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||
| 142 | { type => ARRAYREF, items => { type => HASHREF } } | ||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||
| 144 | =head2 proposals | ||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||
| 146 | Return one proposal per survivor. | ||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||
| 148 | my $proposals = $feedback->proposals; | ||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||
| 150 | =head3 Returns | ||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||
| 152 | An arrayref of hashrefs with these keys: | ||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||
| 154 | =over 4 | ||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||
| 156 | =item * C<kind> - C<constraint> for a numeric comparison that yields an | ||||||||||||||||||||||||||||||||||
| 157 | automatic schema constraint, or C<manual> when a test has to be written by | ||||||||||||||||||||||||||||||||||
| 158 | hand. | ||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||
| 160 | =item * C<survivor_id>, C<file>, C<line>, C<description> - copied from the | ||||||||||||||||||||||||||||||||||
| 161 | survivor, so the proposal can be traced back to the mutation report. | ||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||
| 163 | =item * C<parameter> - the input field the source comparison constrains, | ||||||||||||||||||||||||||||||||||
| 164 | derived from the variable in the comparison. Only present for | ||||||||||||||||||||||||||||||||||
| 165 | C<constraint> proposals. | ||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||
| 167 | =item * C<values> - the boundary values a test should exercise, one either | ||||||||||||||||||||||||||||||||||
| 168 | side of the literal. Only present for C<constraint> proposals. | ||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||
| 170 | =item * C<constraint> - a hashref such as C<< { min => 11 } >>, suitable for | ||||||||||||||||||||||||||||||||||
| 171 | merging into a schema input field. Only present for C<constraint> | ||||||||||||||||||||||||||||||||||
| 172 | proposals. | ||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||
| 174 | =item * C<hint> - human-readable advice for C<manual> proposals. | ||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||
| 176 | =back | ||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||
| 178 | =head3 API SPECIFICATION | ||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||
| 180 | =head4 input | ||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||
| 182 | { self => { type => OBJECT, isa => 'App::Test::Generator::Mutation::Feedback' } } | ||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||
| 184 | =head4 output | ||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||
| 186 | { type => ARRAYREF, items => { type => HASHREF } } | ||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||
| 188 | =head2 apply_to_schema | ||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||
| 190 | Merge constraint proposals into a schema. | ||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||
| 192 | my $applied = $feedback->apply_to_schema($schema); | ||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||
| 194 | =head3 Arguments | ||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||
| 196 | =over 4 | ||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||
| 198 | =item * C<$schema> | ||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||
| 200 | A schema hashref as loaded from YAML. Its C<input> section is modified in | ||||||||||||||||||||||||||||||||||
| 201 | place. | ||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||
| 203 | =back | ||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||
| 205 | =head3 Returns | ||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||
| 207 | An arrayref of change hashrefs, one per constraint added, each with C<field>, | ||||||||||||||||||||||||||||||||||
| 208 | C<constraint>, C<value>, C<survivor_id>, C<file> and C<line>. An empty | ||||||||||||||||||||||||||||||||||
| 209 | arrayref means nothing could be applied; the C<proposals> are still available | ||||||||||||||||||||||||||||||||||
| 210 | for reporting. | ||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||
| 212 | Constraints already present on the field are left alone, as are proposals | ||||||||||||||||||||||||||||||||||
| 213 | whose parameter has no matching input field. | ||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||
| 215 | =head3 API SPECIFICATION | ||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||
| 217 | =head4 input | ||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||
| 219 | { | ||||||||||||||||||||||||||||||||||
| 220 | self => { type => OBJECT, isa => 'App::Test::Generator::Mutation::Feedback' }, | ||||||||||||||||||||||||||||||||||
| 221 | schema => { type => HASHREF }, | ||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||
| 224 | =head4 output | ||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||
| 226 | { type => ARRAYREF, items => { type => HASHREF } } | ||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||
| 228 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||
| 230 | Nigel Horne, C<< <njh at nigelhorne.com> >> | ||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||
| 232 | =head1 LICENCE AND COPYRIGHT | ||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||
| 234 | Copyright 2026 Nigel Horne. | ||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||
| 236 | Usage is subject to the terms of GPL2. | ||||||||||||||||||||||||||||||||||
| 237 | If you use it, | ||||||||||||||||||||||||||||||||||
| 238 | please let me know. | ||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||
| 240 | =cut | ||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||
| 242 | # -------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 243 | # A variable on the left of a comparison: $name, | ||||||||||||||||||||||||||||||||||
| 244 | # $self->{name}, $self->{name}[0] and so on. The | ||||||||||||||||||||||||||||||||||
| 245 | # last identifier is the parameter name. | ||||||||||||||||||||||||||||||||||
| 246 | # -------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 247 | 184 | my $COMPARISON_RE = qr{ | |||||||||||||||||||||||||||||||||
| 248 | (?<var>\$[A-Za-z_]\w* | ||||||||||||||||||||||||||||||||||
| 249 | (?:\s*(?:->\s*\{?\s*[A-Za-z_]\w*\s*\}?|\[\s*-?\d+\s*\])*) | ||||||||||||||||||||||||||||||||||
| 250 | ) | ||||||||||||||||||||||||||||||||||
| 251 | \s*(?<op>>=|<=|==|!=|>|<)\s* | ||||||||||||||||||||||||||||||||||
| 252 | (?<num>-?\d+(?:\.\d+)?) | ||||||||||||||||||||||||||||||||||
| 253 | }x; | ||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||
| 255 | 6 | ▶ | sub new { | ||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=8 SCAR=21.5
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 256 | 6 | my ($class, %args) = @_; | |||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||
| 258 | croak 'mutation_results is required' | ||||||||||||||||||||||||||||||||||
| 259 | 6 | ▶ | unless defined($args{mutation_results}); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||
| 261 | 6 | my $results = $args{mutation_results}; | |||||||||||||||||||||||||||||||||
| 262 | 6 | ▶ | if(!ref($results)) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 263 | 6 | ▶ | croak "mutation_results '$results' does not exist" | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 264 | unless -f $results; | ||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||
| 266 | 6 | ▶ | open(my $fh, '<', $results) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 267 | or croak "Cannot read mutation_results '$results': $!"; | ||||||||||||||||||||||||||||||||||
| 268 | 6 | my $raw = do { local $/; <$fh> }; | |||||||||||||||||||||||||||||||||
| 269 | 6 | close($fh); | |||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||
| 271 | 6 | $results = eval { decode_json($raw) }; | |||||||||||||||||||||||||||||||||
| 272 | 6 | ▶ | croak "mutation_results '$args{mutation_results}' is not valid JSON: $@" | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 273 | if $@; | ||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||
| 276 | 6 | ▶ | croak 'mutation_results must decode to a hashref' | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 277 | unless ref($results) eq 'HASH'; | ||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||
| 279 | return bless { | ||||||||||||||||||||||||||||||||||
| 280 | results => $results, | ||||||||||||||||||||||||||||||||||
| 281 | module => $args{module}, | ||||||||||||||||||||||||||||||||||
| 282 | 6 | ▶ | source_root => $args{source_root} // '.', | ||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{"source_root"} // "."
MC/DC100%1/1
$args{"source_root"} // "."
$args{"source_root"}
Truth table100%2/2
A
A= $args{"source_root"}
| |||||||||||||||||||||||||||||||||||
| 283 | }, $class; | ||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||
| 286 | 6 | ▶ | sub survivors { | ||||||||||||||||||||||||||||||||
|
Subroutine
survivors: called CC=5 SCAR=17.5
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 287 | 6 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||
| 289 | 6 | my %seen; | |||||||||||||||||||||||||||||||||
| 290 | my @survivors = grep { | ||||||||||||||||||||||||||||||||||
| 291 | (my $status = $_->{status} // 'Survived') eq 'Survived' | ||||||||||||||||||||||||||||||||||
| 292 | 24 | ▶ | && !$seen{ $_->{id} // '' }++ | ||||||||||||||||||||||||||||||||
|
Condition42%3/7
(my $status = $_->{'status'} // 'Survived') eq 'Survived' && !$seen{$_->{'id'} // ''}++
$_->{"status"} // "Survived"
$_->{"id"} // ""
MC/DC0%0/2
(my $status = $_->{'status'} // 'Survived') eq 'Survived' && !$seen{$_->{'id'} // ''}++
$_->{"status"}
!$seen{$_->{'id'} // ''}++
MC/DC0%0/1
$_->{"id"} // ""
$_->{"id"}
Truth table33%1/3
A && not(B)
A= $_->{"status"}B= !$seen{$_->{'id'} // ''}++
Truth table50%1/2
A
A= $_->{"id"}
| |||||||||||||||||||||||||||||||||||
| 293 | 6 | ▶ | } @{ $self->{results}{survived} || [] }; | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'results'}{'survived'} || []
MC/DC0%0/1
$self->{'results'}{'survived'} || []
$self->{'results'}{'survived'}
Truth table50%1/2
A
A= $self->{'results'}{'survived'}
| |||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||
| 295 | 6 | return [ grep { $self->_matches_module($_) } @survivors ]; | |||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||
| 298 | 6 | ▶ | sub proposals { | ||||||||||||||||||||||||||||||||
|
Subroutine
proposals: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 299 | 6 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||
| 301 | 6 | ▶ | $self->{proposals} //= [ map { $self->_proposal_for($_) } @{ $self->survivors } ]; | ||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"proposals"} //= [map({$self->_proposal_for($_);} @{$self->survivors;})]
MC/DC100%1/1
$self->{"proposals"} //= [map({$self->_proposal_for($_);} @{$self->survivors;})]
$self->{"proposals"}
Truth table100%2/2
A
A= $self->{"proposals"}
| |||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||
| 303 | 6 | return $self->{proposals}; | |||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||
| 306 | 4 | ▶ | sub apply_to_schema { | ||||||||||||||||||||||||||||||||
|
Subroutine
apply_to_schema: called CC=14 SCAR=27.1
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 307 | 4 | my ($self, $schema) = @_; | |||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||
| 309 | 4 | ▶ | croak 'apply_to_schema needs a schema hashref' | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 310 | unless ref($schema) eq 'HASH'; | ||||||||||||||||||||||||||||||||||
| 311 | 4 | ▶ | return [] unless ref($schema->{input}) eq 'HASH'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||
| 313 | 4 | my %field_for; | |||||||||||||||||||||||||||||||||
| 314 | 4 | foreach my $field (keys %{ $schema->{input} }) { | |||||||||||||||||||||||||||||||||
| 315 | 4 | ▶ | $field_for{ _normalise($field) } //= $field; | ||||||||||||||||||||||||||||||||
|
Condition33%1/3
$field_for{_normalise($field)} //= $field
MC/DC0%0/2
$field_for{_normalise($field)} //= $field
$field_for{_normalise($field)}
$field
Truth table33%1/3
A //= B
A= $field_for{_normalise($field)}B= $field
| |||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||
| 318 | 4 | my @applied; | |||||||||||||||||||||||||||||||||
| 319 | my %already; | ||||||||||||||||||||||||||||||||||
| 320 | 4 | foreach my $proposal (@{ $self->proposals }) { | |||||||||||||||||||||||||||||||||
| 321 | 12 | ▶ | next unless $proposal->{kind} eq 'constraint'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||
| 323 | 8 | my $field = $field_for{ _normalise($proposal->{parameter}) }; | |||||||||||||||||||||||||||||||||
| 324 | 8 | ▶ | next unless defined($field); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||
| 326 | 8 | my $spec = $schema->{input}{$field}; | |||||||||||||||||||||||||||||||||
| 327 | 8 | ▶ | next unless ref($spec) eq 'HASH'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||
| 329 | 8 | foreach my $constraint (sort keys %{ $proposal->{constraint} }) { | |||||||||||||||||||||||||||||||||
| 330 | 8 | my $value = $proposal->{constraint}{$constraint}; | |||||||||||||||||||||||||||||||||
| 331 | 8 | ▶ | next if exists($spec->{$constraint}) && defined($spec->{$constraint}); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $spec->{$constraint} and defined $spec->{$constraint}
MC/DC50%1/2
exists $spec->{$constraint} and defined $spec->{$constraint}
exists $spec->{$constraint}
defined $spec->{$constraint}
Truth table66%2/3
A and B
A= exists $spec->{$constraint}B= defined $spec->{$constraint}
| |||||||||||||||||||||||||||||||||||
| 332 | 7 | ▶ | next if $already{"$field\0$constraint"}++; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||
| 334 | 7 | $spec->{$constraint} = $value; | |||||||||||||||||||||||||||||||||
| 335 | $spec->{_constraint_source} = { | ||||||||||||||||||||||||||||||||||
| 336 | 7 | ▶ | %{ $spec->{_constraint_source} || {} }, | ||||||||||||||||||||||||||||||||
|
Condition100%2/2
$spec->{'_constraint_source'} || {}
MC/DC100%1/1
$spec->{'_constraint_source'} || {}
$spec->{'_constraint_source'}
Truth table100%2/2
A
A= $spec->{'_constraint_source'}
| |||||||||||||||||||||||||||||||||||
| 337 | $constraint => 'mutation', | ||||||||||||||||||||||||||||||||||
| 338 | }; | ||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||
| 340 | push @applied, { | ||||||||||||||||||||||||||||||||||
| 341 | field => $field, | ||||||||||||||||||||||||||||||||||
| 342 | constraint => $constraint, | ||||||||||||||||||||||||||||||||||
| 343 | value => $value, | ||||||||||||||||||||||||||||||||||
| 344 | survivor_id => $proposal->{survivor_id}, | ||||||||||||||||||||||||||||||||||
| 345 | file => $proposal->{file}, | ||||||||||||||||||||||||||||||||||
| 346 | line => $proposal->{line}, | ||||||||||||||||||||||||||||||||||
| 347 | 7 | }; | |||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||
| 351 | 4 | return \@applied; | |||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||
| 354 | 24 | ▶ | sub _matches_module { | ||||||||||||||||||||||||||||||||
|
Subroutine
_matches_module: called CC=6 SCAR=18.8
| |||||||||||||||||||||||||||||||||||
| 355 | 24 | my ($self, $survivor) = @_; | |||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||
| 357 | 24 | ▶ | return 1 unless defined($self->{module}) && length($self->{module}); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self->{"module"} and length $self->{"module"}
MC/DC0%0/2
defined $self->{"module"} and length $self->{"module"}
defined $self->{"module"}
length $self->{"module"}
Truth table33%1/3
A and B
A= defined $self->{"module"}B= length $self->{"module"}
| |||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||
| 359 | 24 | my $expected = $self->{module}; | |||||||||||||||||||||||||||||||||
| 360 | 24 | $expected =~ s{::}{/}g; | |||||||||||||||||||||||||||||||||
| 361 | 24 | $expected .= '.pm'; | |||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||
| 363 | 24 | ▶ | my $file = $survivor->{file} // ''; | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$survivor->{"file"} // ""
MC/DC0%0/1
$survivor->{"file"} // ""
$survivor->{"file"}
Truth table50%1/2
A
A= $survivor->{"file"}
| |||||||||||||||||||||||||||||||||||
| 364 | 24 | $file =~ s{^\./}{}; | |||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||
| 366 | 24 | ▶ | return ($file eq $expected) || ($file =~ m{(?:^|/)\Q$expected\E$}) ? 1 : 0; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$file eq $expected or $file =~ m[(?:^|/)\Q$expected\E$]
MC/DC50%1/2
$file eq $expected or $file =~ m[(?:^|/)\Q$expected\E$]
$file eq $expected
$file =~ m[(?:^|/)\Q$expected\E$]
Truth table66%2/3
A or B
A= $file eq $expectedB= $file =~ m[(?:^|/)\Q$expected\E$]
| |||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||
| 369 | 15 | ▶ | sub _proposal_for { | ||||||||||||||||||||||||||||||||
|
Subroutine
_proposal_for: called CC=9 SCAR=23.1
| |||||||||||||||||||||||||||||||||||
| 370 | 15 | my ($self, $survivor) = @_; | |||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||
| 372 | my %proposal = ( | ||||||||||||||||||||||||||||||||||
| 373 | kind => 'manual', | ||||||||||||||||||||||||||||||||||
| 374 | survivor_id => $survivor->{id}, | ||||||||||||||||||||||||||||||||||
| 375 | file => $survivor->{file}, | ||||||||||||||||||||||||||||||||||
| 376 | line => $survivor->{line}, | ||||||||||||||||||||||||||||||||||
| 377 | description => $survivor->{description}, | ||||||||||||||||||||||||||||||||||
| 378 | hint => $survivor->{hint} | ||||||||||||||||||||||||||||||||||
| 379 | 15 | ▶ | // 'Review the surviving mutant and add a test that tells it apart', | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$survivor->{"hint"} // "Review the surviving mutant and add a test that tells it apart"
MC/DC0%0/1
$survivor->{"hint"} // "Review the surviving mutant and add a test that tells it apart"
$survivor->{"hint"}
Truth table50%1/2
A
A= $survivor->{"hint"}
| |||||||||||||||||||||||||||||||||||
| 380 | ); | ||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||
| 382 | 15 | ▶ | my $id = $survivor->{id} // ''; | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$survivor->{"id"} // ""
MC/DC0%0/1
$survivor->{"id"} // ""
$survivor->{"id"}
Truth table50%1/2
A
A= $survivor->{"id"}
| |||||||||||||||||||||||||||||||||||
| 383 | 15 | my ($line, $column) = $id =~ /^NUM_BOUNDARY_(\d+)_(\d+)_/; | |||||||||||||||||||||||||||||||||
| 384 | 15 | ▶ | my ($original) = ($survivor->{description} // '') | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$survivor->{"description"} // ""
MC/DC0%0/1
$survivor->{"description"} // ""
$survivor->{"description"}
Truth table50%1/2
A
A= $survivor->{"description"}
| |||||||||||||||||||||||||||||||||||
| 385 | =~ /Numeric boundary flip\s+(\S+)\s+to\s+\S+/; | ||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||
| 387 | 15 | ▶ | return \%proposal unless defined($line) && defined($original); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $line and defined $original
MC/DC50%1/2
defined $line and defined $original
defined $line
defined $original
Truth table66%2/3
A and B
A= defined $lineB= defined $original
| |||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||
| 389 | my ($var, $literal) = $self->_numeric_comparison( | ||||||||||||||||||||||||||||||||||
| 390 | 10 | $survivor->{file}, $line, $column, $original, | |||||||||||||||||||||||||||||||||
| 391 | ); | ||||||||||||||||||||||||||||||||||
| 392 | 10 | ▶ | return \%proposal unless defined($var) && defined($literal); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $var and defined $literal
MC/DC0%0/2
defined $var and defined $literal
defined $var
defined $literal
Truth table33%1/3
A and B
A= defined $varB= defined $literal
| |||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||
| 394 | 10 | my $constraint = _constraint_for($original, $literal); | |||||||||||||||||||||||||||||||||
| 395 | 10 | ▶ | return \%proposal unless $constraint; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||
| 397 | 10 | $proposal{kind} = 'constraint'; | |||||||||||||||||||||||||||||||||
| 398 | 10 | $proposal{parameter} = _parameter_name($var); | |||||||||||||||||||||||||||||||||
| 399 | 10 | $proposal{values} = [ $literal - 1, $literal, $literal + 1 ]; | |||||||||||||||||||||||||||||||||
| 400 | 10 | $proposal{constraint} = $constraint; | |||||||||||||||||||||||||||||||||
| 401 | 10 | $proposal{hint} = "Add cases at the boundary of $original $literal"; | |||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||
| 403 | 10 | return \%proposal; | |||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||
| 406 | # Read the line a mutant targets and find the comparison it mutated. When a | ||||||||||||||||||||||||||||||||||
| 407 | # line holds several comparisons, the one nearest the mutant's column wins. | ||||||||||||||||||||||||||||||||||
| 408 | 10 | ▶ | sub _numeric_comparison { | ||||||||||||||||||||||||||||||||
|
Subroutine
_numeric_comparison: called CC=8 SCAR=22.9
| |||||||||||||||||||||||||||||||||||
| 409 | 10 | my ($self, $file, $line_number, $column, $original) = @_; | |||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||
| 411 | 10 | my $source = $self->_source_line($file, $line_number); | |||||||||||||||||||||||||||||||||
| 412 | 10 | ▶ | return unless defined($source); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||
| 414 | 10 | my ($best_var, $best_literal, $best_distance); | |||||||||||||||||||||||||||||||||
| 415 | 10 | ▶ | while($source =~ /$COMPARISON_RE/g) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 416 | 10 | ▶ | next unless $+{op} eq $original; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||
| 418 | my $distance = (defined($column) && length($column)) | ||||||||||||||||||||||||||||||||||
| 419 | 10 | ▶ | ? abs(($-[0] + index($&, $+{op}) + 1) - $column) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $column and length $column
MC/DC0%0/2
defined $column and length $column
defined $column
length $column
Truth table33%1/3
A and B
A= defined $columnB= length $column
| |||||||||||||||||||||||||||||||||||
| 420 | : 0; | ||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||
| 422 | 10 | ▶ | next if defined($best_distance) && ($distance >= $best_distance); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $best_distance and $distance >= $best_distance
MC/DC0%0/2
defined $best_distance and $distance >= $best_distance
defined $best_distance
$distance >= $best_distance
Truth table33%1/3
A and B
A= defined $best_distanceB= $distance >= $best_distance
| |||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||
| 424 | 10 | ($best_var, $best_literal, $best_distance) = ($+{var}, $+{num}, $distance); | |||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||
| 427 | 10 | return ($best_var, $best_literal); | |||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||
| 430 | 10 | ▶ | sub _source_line { | ||||||||||||||||||||||||||||||||
|
Subroutine
_source_line: called CC=8 SCAR=23.2
| |||||||||||||||||||||||||||||||||||
| 431 | 10 | my ($self, $file, $line_number) = @_; | |||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||
| 433 | 10 | ▶ | return unless defined($file) && defined($line_number); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $file and defined $line_number
MC/DC0%0/2
defined $file and defined $line_number
defined $file
defined $line_number
Truth table33%1/3
A and B
A= defined $fileB= defined $line_number
| |||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||
| 435 | my $path = File::Spec->file_name_is_absolute($file) | ||||||||||||||||||||||||||||||||||
| 436 | ? $file | ||||||||||||||||||||||||||||||||||
| 437 | 10 | ▶ | : File::Spec->catfile($self->{source_root}, $file); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 438 | 10 | ▶ | return unless -f $path; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||
| 440 | 10 | ▶ | open(my $fh, '<', $path) or return; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 441 | 10 | my $current = 0; | |||||||||||||||||||||||||||||||||
| 442 | 10 | ▶ | while(my $line = <$fh>) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 443 | 110 | ▶ | if(++$current == $line_number) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 444 | 10 | close($fh); | |||||||||||||||||||||||||||||||||
| 445 | 10 | chomp($line); | |||||||||||||||||||||||||||||||||
| 446 | 10 | return $line; | |||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||
| 449 | 0 | close($fh); | |||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||
| 451 | 0 | return; | |||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||
| 454 | # Integer literals only: one step either side of a float is not a boundary | ||||||||||||||||||||||||||||||||||
| 455 | # in the same sense, so those survivors stay manual proposals. | ||||||||||||||||||||||||||||||||||
| 456 | 10 | ▶ | sub _constraint_for { | ||||||||||||||||||||||||||||||||
|
Subroutine
_constraint_for: called CC=7 SCAR=24.4
| |||||||||||||||||||||||||||||||||||
| 457 | 10 | my ($operator, $literal) = @_; | |||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||
| 459 | 10 | ▶ | return unless defined($literal) && ($literal =~ /^-?\d+$/); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $literal and $literal =~ /^-?\d+$/
MC/DC0%0/2
defined $literal and $literal =~ /^-?\d+$/
defined $literal
$literal =~ /^-?\d+$/
Truth table33%1/3
A and B
A= defined $literalB= $literal =~ /^-?\d+$/
| |||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||
| 461 | 10 | ▶ | return { min => $literal + 1 } if $operator eq '>'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 462 | 5 | ▶ | return { min => $literal } if $operator eq '>='; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 463 | 5 | ▶ | return { max => $literal - 1 } if $operator eq '<'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 464 | 0 | ▶ | return { max => $literal } if $operator eq '<='; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 465 | 0 | return; | |||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||
| 468 | 10 | ▶ | sub _parameter_name { | ||||||||||||||||||||||||||||||||
|
Subroutine
_parameter_name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 469 | 10 | my ($var) = @_; | |||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||
| 471 | 10 | my @identifiers = $var =~ /([A-Za-z_]\w*)/g; | |||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||
| 473 | 10 | return $identifiers[-1]; | |||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||
| 476 | 12 | ▶ | sub _normalise { | ||||||||||||||||||||||||||||||||
|
Subroutine
_normalise: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||
| 477 | 12 | my ($name) = @_; | |||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||
| 479 | 12 | ▶ | $name = '' unless defined($name); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 480 | 12 | $name = lc($name); | |||||||||||||||||||||||||||||||||
| 481 | 12 | $name =~ s/[^a-z0-9]//g; | |||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||
| 483 | 12 | return $name; | |||||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||
| 486 | 184 | 1; | |||||||||||||||||||||||||||||||||