App-Test-Generator
view release on metacpan or search on metacpan
t/Mutant_unit.t view on Meta::CPAN
)
},
qr/Missing required attribute: id/,
'missing id croaks',
);
};
subtest 'new() croaks when description is missing' => sub {
throws_ok(
sub {
App::Test::Generator::Mutant->new(
id => 'X', original => '>', line => 1,
transform => sub { 1 },
)
},
qr/Missing required attribute: description/,
'missing description croaks',
);
};
subtest 'new() croaks when original is missing' => sub {
throws_ok(
sub {
App::Test::Generator::Mutant->new(
id => 'X', description => 'x', line => 1,
transform => sub { 1 },
)
},
qr/Missing required attribute: original/,
'missing original croaks',
);
};
subtest 'new() croaks when line is missing' => sub {
throws_ok(
sub {
App::Test::Generator::Mutant->new(
id => 'X', description => 'x', original => '>',
transform => sub { 1 },
)
},
qr/Missing required attribute: line/,
'missing line croaks',
);
};
subtest 'new() croaks when transform is missing' => sub {
throws_ok(
sub {
App::Test::Generator::Mutant->new(
id => 'X', description => 'x', original => '>', line => 1,
)
},
qr/Missing required attribute: transform/,
'missing transform croaks',
);
};
subtest 'new() croaks when transform is not a CODE reference' => sub {
throws_ok(
sub { _mutant(transform => 'not_a_coderef') },
qr/transform must be a CODE reference/,
'string transform croaks',
);
throws_ok(
sub {
App::Test::Generator::Mutant->new(
id => 'X',
description => 'x',
original => '>',
line => 1,
transform => undef,
)
},
qr/transform must be a CODE reference/,
'undef transform croaks',
);
};
subtest 'new() type and group default to undef when not supplied' => sub {
my $m = _mutant();
is($m->type, undef, 'type defaults to undef');
is($m->group, undef, 'group defaults to undef');
};
subtest 'new() each call produces a distinct object' => sub {
my $m1 = _mutant();
my $m2 = _mutant();
isnt($m1, $m2, 'distinct objects returned');
};
# ==================================================================
# id()
#
# POD spec:
# Returns the id string.
# Read-only â argument is ignored.
# ==================================================================
subtest 'id() returns the stored id' => sub {
my $m = _mutant(id => 'NUM_BOUNDARY_42_7_!=');
is($m->id, 'NUM_BOUNDARY_42_7_!=', 'id returned correctly');
};
subtest 'id() is read-only â value unchanged after write attempt' => sub {
my $m = _mutant(id => 'ORIGINAL');
my $orig = $m->id;
eval { $m->id('CHANGED') };
is($m->id, $orig, 'id unchanged after write attempt');
};
# ==================================================================
# description()
#
# POD spec:
# Returns the description string.
# ==================================================================
subtest 'description() returns the stored description' => sub {
my $m = _mutant(description => 'Flip > to <');
is($m->description, 'Flip > to <', 'description returned correctly');
( run in 1.093 second using v1.01-cache-2.11-cpan-9581c071862 )