6 use Test::More tests => 27;
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");
107 local $SIG{__WARN__} = sub {
108 $_[0] =~ /\QExecution of finally() block CODE(0x\E.+\Q) resulted in an exception/
123 is( scalar @warnings, 2, 'warnings from both fatal finally blocks' );
125 my @originals = sort map { $_ =~ /Original exception text follows:\n\n(.+)/s } @warnings;
127 like $originals[0], qr/fin 1 at/, 'First warning contains original exception';
128 like $originals[1], qr/fin 3 at/, 'Second warning contains original exception';