4 use Test::More tests => 30;
10 fail('Cannot go into catch block because we did not throw an exception')
12 pass('Moved into finally from try');
18 ok($_ =~ /Die/, 'Error text as expected');
19 pass('Into catch block as we died in try');
21 pass('Moved into finally from catch');
27 pass('Moved into finally from catch');
29 ok($_ =~ /Die/, 'Error text as expected');
35 pass('Moved into finally block when try throws an exception and we have no catch block');
41 pass('First finally clause run');
43 pass('Second finally clause run');
50 fail("errors reported: @_");
52 pass("no error reported") ;
59 is_deeply(\@_, [ "Die\n" ], "finally got passed the exception");
70 pass("finally called");
76 is($_, "foo", "not localized in try");
81 is(scalar(@_), 0, "nothing in \@_ (finally)");
82 is($_, "foo", "\$_ not localized (finally)");
84 is($_, "foo", "same afterwards");
88 is($_, "foo", "not localized in try");
92 is($_[0], "bar\n", "error in \@_ (catch)");
93 is($_, "bar\n", "error in \$_ (catch)");
96 is(scalar(@_), 1, "error in \@_ (finally)");
97 is($_[0], "bar\n", "error in \@_ (finally)");
98 is($_, "foo", "\$_ not localized (finally)");
100 is($_, "foo", "same afterwards");
104 local $SIG{__WARN__} = sub {
105 $_[0] =~ /\QExecution of finally() block CODE(0x\E.+\Q) resulted in an exception/
120 is( scalar @warnings, 2, 'warnings from both fatal finally blocks' );
122 my @originals = sort map { $_ =~ /Original exception text follows:\n\n(.+)/s } @warnings;
124 like $originals[0], qr/fin 1 at/, 'First warning contains original exception';
125 like $originals[1], qr/fin 3 at/, 'Second warning contains original exception';
132 pass('before skip in try');
139 ok $finally, 'finally ran';