App-Test-Generator
view release on metacpan or search on metacpan
populating the context/line_content fields on the Mutant objects
it constructs; both are now wired through.
- Fix Analyzer::SideEffect.pm and Analyzer::Complexity.pm counting
IO/exec keywords, branch/logic/exception keywords, and the
literal ? character when they merely appeared inside a string
literal or comment (e.g. "Are you sure?" or a # comment containing
"die"); source is now stripped of string and comment content
before these keyword/operator counts are taken.
- Fix Analyzer::Return.pm's \$self(?!->) returns_self pattern
matching the \$self prefix of any longer variable name (e.g.
\$self_backup, \$selfish); added a \b word boundary. Also fixed
all three return-pattern matches running as a single non-/g match,
so a method with several qualifying return statements only ever
contributed one evidence entry instead of one per occurrence.
- Fix Mutation::BooleanNegation and Mutation::ReturnUndef mutating
only the first PPI token of a multi-token return expression (e.g.
$self->{value}), since $ret->schild(1) captures just the leading
Symbol token of a chained/dereferencing expression; this produced
broken mutants like 'return !($self)->{value};' and
'return undef->{value};' that die at runtime rather than testing
the intended boolean/undef substitution. Both now resolve the
MANIFEST.SKIP view on Meta::CPAN
\bblibdirs\.ts$ # 6.18 through 6.25 generated this
# Avoid Module::Build generated and utility files.
\bBuild$
\b_build/
\bBuild.bat$
\bBuild.COM$
\bBUILD.COM$
\bbuild.com$
# Avoid temp and backup files.
~$
\.old$
\#$
\b\.#
\.bak$
\.tmp$
\.#
\.rej$
schemas\.yml$
\.swp$
lib/App/Test/Generator/Analyzer/Return.pm view on Meta::CPAN
category => 'return',
signal => 'returns_property',
value => $1,
weight => $WEIGHT_RETURNS_PROPERTY,
);
}
# --------------------------------------------------
# Detect: return $self
# \b after \$self prevents matching variable names that
# merely start with "self" (e.g. $self_backup, $selfish);
# the negative lookahead then excludes return $self->{...}
# which is a property return handled above. Matched with
# /g for the same multi-occurrence reason as above.
# --------------------------------------------------
while($source =~ /return\s+\$self\b(?!->)/g) {
$add->(
category => 'return',
signal => 'returns_self',
weight => $WEIGHT_RETURNS_SELF,
);
t/Analyzer-Return.t view on Meta::CPAN
ok(scalar @prop > 0, 'returns_property detected in multi-signal method');
done_testing();
};
# ==================================================================
# analyze -- returns_self is NOT triggered by variable names
# that merely start with "self" (overly broad \$self(?!->))
# --------------------------------------------------
# Regression: \$self(?!->) without a word boundary matched the
# "$self" prefix of any longer variable name, e.g. $self_backup,
# so "return $self_backup;" was wrongly classified as returns_self.
# ==================================================================
subtest 'analyze: returns_self not triggered by $self-prefixed variable names' => sub {
my $ev = _evidence_after('sub foo { my $self_backup = 1; return $self_backup; }');
my @self_ev = grep { $_->{signal} eq 'returns_self' } @{$ev};
is(scalar @self_ev, 0, 'returns_self not triggered by $self_backup');
$ev = _evidence_after('sub foo { my $selfish = 1; return $selfish; }');
@self_ev = grep { $_->{signal} eq 'returns_self' } @{$ev};
is(scalar @self_ev, 0, 'returns_self not triggered by $selfish');
done_testing();
};
# ==================================================================
# analyze -- each occurrence of a signal contributes its own
( run in 0.939 second using v1.01-cache-2.11-cpan-804bf51f3ce )