5 use Test::Builder::Tester tests => 3;
8 BEGIN { use_ok( 'Test::Exception' ) };
10 sub works {return shift};
11 sub dies { die 'oops' };
13 my $filename = sub { return (caller)[1] }->();
15 lives_and {is works(42), 42} 'lives_and, no_exception & success';
17 test_out('not ok 1 - lives_and, no_exception & failure');
19 test_err("# got: '42'");
20 test_err("# expected: '24'");
21 lives_and {is works(42), 24} 'lives_and, no_exception & failure';
23 test_out('not ok 2 - lives_and, exception');
25 test_err("# died: oops at $filename line 11.");
26 lives_and {is dies(42), 42} 'lives_and, exception';
28 test_out('ok 3 - The object isa Foo' );
29 lives_and { isa_ok( bless({}, 'Foo'), 'Foo') };
31 test_test('lives_and works');