VERSION
Version 0.34
METHODS
applies_to
Returns true if the document contains any if or unless compound statements that this mutator can target.
mutate
Walk a PPI document and generate one mutant for each if or unless statement, inverting the keyword to its opposite. This detects cases where the test suite does not exercise both branches of a conditional.
my $mutation = App::Test::Generator::Mutation::ConditionalInversion->new;
my $doc = PPI::Document->new(\$source);
my @mutants = $mutation->mutate($doc);
for my $m (@mutants) {
print $m->id, ': ', $m->description, "\n";
}
Arguments
$selfAn instance of
App::Test::Generator::Mutation::ConditionalInversion.$docA PPI::Document object representing the parsed source file to mutate. The document is not modified by this method.
Returns
A list of App::Test::Generator::Mutant objects, one per if or unless statement found in the document. Returns an empty list if no qualifying statements are found.
Each mutant carries a transform closure that when called with a fresh PPI::Document copy will flip the targeted keyword from if to unless or vice versa, targeting the exact statement by line and column number.
Notes
Multiple conditionals on the same source line are each mutated independently. Mutant IDs include both line and column number to ensure uniqueness.
API specification
input
{
self => {
type => OBJECT,
isa => 'App::Test::Generator::Mutation::ConditionalInversion',
},
doc => {
type => OBJECT,
isa => 'PPI::Document',
},
}
output
{
type => ARRAYREF,
elements => {
type => OBJECT,
isa => 'App::Test::Generator::Mutant',
},
}