6 use Test::More tests => 24;
8 BEGIN { use_ok 'Try::Tiny' };
13 fail('Cannot go into catch block because we did not throw an exception')
15 pass('Moved into finally from try');
21 ok($_ =~ /Die/, 'Error text as expected');
22 pass('Into catch block as we died in try');
24 pass('Moved into finally from catch');
30 pass('Moved into finally from catch');
32 ok($_ =~ /Die/, 'Error text as expected');
38 pass('Moved into finally block when try throws an exception and we have no catch block');
44 pass('First finally clause run');
46 pass('Second finally clause run');
53 fail("errors reported: @_");
55 pass("no error reported") ;
62 is_deeply(\@_, [ "Die\n" ], "finally got passed the exception");
73 pass("finally called");
79 is($_, "foo", "not localized in try");
84 is(scalar(@_), 0, "nothing in \@_ (finally)");
85 is($_, "foo", "\$_ not localized (finally)");
87 is($_, "foo", "same afterwards");
91 is($_, "foo", "not localized in try");
95 is($_[0], "bar\n", "error in \@_ (catch)");
96 is($_, "bar\n", "error in \$_ (catch)");
99 is(scalar(@_), 1, "error in \@_ (finally)");
100 is($_[0], "bar\n", "error in \@_ (finally)");
101 is($_, "foo", "\$_ not localized (finally)");
103 is($_, "foo", "same afterwards");