| File: | blib/lib/App/Test/Generator/Mutation/Base.pm |
| Coverage: | 100.0% |
| line | stmt | bran | cond | sub | time | code |
|---|---|---|---|---|---|---|
| 1 | package App::Test::Generator::Mutation::Base; | |||||
| 2 | ||||||
| 3 | 14 14 14 | 200392 12 173 | use strict; | |||
| 4 | 14 14 14 | 27 14 254 | use warnings; | |||
| 5 | 14 14 14 | 24 12 909 | use Carp qw(croak); | |||
| 6 | ||||||
| 7 | our $VERSION = '0.36'; | |||||
| 8 | ||||||
| 9 - 46 | =head1 VERSION
Version 0.36
=head1 DESCRIPTION
Abstract base class for all mutation strategies in
App::Test::Generator. Subclasses must implement both
C<applies_to> and C<mutate>.
=head2 new
Construct a new mutation strategy object.
my $strategy = My::Mutation::Subclass->new;
=head3 Arguments
None.
=head3 Returns
A blessed hashref of the subclass type.
=head3 API specification
=head4 input
{}
=head4 output
{
type => OBJECT,
isa => 'App::Test::Generator::Mutation::Base',
}
=cut | |||||
| 47 | ||||||
| 48 | 352 | 1187979 | sub new { bless {}, shift } | |||
| 49 | ||||||
| 50 - 86 | =head2 applies_to
Return true if this mutation strategy applies to the
given PPI document. Subclasses must override this method.
if ($strategy->applies_to($doc)) {
my @mutants = $strategy->mutate($doc);
}
=head3 Arguments
=over 4
=item * C<$doc>
A L<PPI::Document> object.
=back
=head3 Returns
A boolean. Croaks if called on the base class directly.
=head3 API specification
=head4 input
{
self => { type => OBJECT, isa => 'App::Test::Generator::Mutation::Base' },
doc => { type => OBJECT, isa => 'PPI::Document' },
}
=head4 output
{ type => SCALAR }
=cut | |||||
| 87 | ||||||
| 88 | sub applies_to { | |||||
| 89 | 4 | 1914 | croak ref(shift) . '::applies_to() must be implemented by subclass'; | |||
| 90 | } | |||||
| 91 | ||||||
| 92 - 131 | =head2 mutate
Generate and return a list of mutants for the given PPI
document. Subclasses must override this method.
my @mutants = $strategy->mutate($doc);
=head3 Arguments
=over 4
=item * C<$doc>
A L<PPI::Document> object representing the source file
to mutate. Must not be modified by this method.
=back
=head3 Returns
A list of L<App::Test::Generator::Mutant> objects.
Croaks if called on the base class directly.
=head3 API specification
=head4 input
{
self => { type => OBJECT, isa => 'App::Test::Generator::Mutation::Base' },
doc => { type => OBJECT, isa => 'PPI::Document' },
}
=head4 output
{
type => ARRAYREF,
elements => { type => OBJECT, isa => 'App::Test::Generator::Mutant' },
}
=cut | |||||
| 132 | ||||||
| 133 | sub mutate { | |||||
| 134 | 4 | 1075 | croak ref(shift) . '::mutate() must be implemented by subclass'; | |||
| 135 | } | |||||
| 136 | ||||||
| 137 | 1; | |||||