Test-Exception
view release on metacpan or search on metacpan
t/lives_and.t view on Meta::CPAN
use Test::More;
diag "\$Test::More::VERSION = $Test::More::VERSION";
BEGIN { use_ok( 'Test::Exception' ) };
sub works {return shift};
sub dies { die 'oops' };
my $die_line = __LINE__ - 1;
my $filename = sub { return (caller)[1] }->();
lives_and {is works(42), 42} 'lives_and, no_exception & success';
test_out('not ok 1 - lives_and, no_exception & failure');
test_fail(+3);
test_err("# got: '42'");
test_err("# expected: '24'");
lives_and {is works(42), 24} 'lives_and, no_exception & failure';
test_out('not ok 2 - lives_and, exception');
use Test::Builder::Tester tests => 13;
use Test::More;
BEGIN { use_ok( 'Test::Exception' ) };
sub div {
my ($a, $b) = @_;
return( $a / $b );
};
my $filename = sub { return (caller)[1] }->();
{
my $ok = dies_ok { div(1, 0) } 'dies_ok passed on die';
ok($ok, 'dies_ok returned true when block dies');
}
{
test_out('not ok 1 - dies_ok failed');
test_fail( +1 );
( run in 1.650 second using v1.01-cache-2.11-cpan-a3c8064c92c )