Is there a way to write tests for Perl calls that you expect to die? I would like to verify that some calls will die with poorly formatted inputs.
sub routine_a {
my $arg = shift;
die if $arg eq 'FOO';
print "routine_a: $arg\n";
}
sub routine_b {
my $arg = shift;
die if $arg eq 'BAR';
print "routine_b: $arg\n";
}
sub test_all {
assert( routine_a("blah") );
assert( routine_b("blab") );
assert_death( routine_a("FOO") );
assert_death( routine_b("BAR") );
}
source
share