4 use Test::More tests => 30;
11 fail('Cannot go into catch block because we did not throw an exception')
13 pass('Moved into finally from try');
19 ok($_ =~ /Die/, 'Error text as expected');
20 pass('Into catch block as we died in try');
22 pass('Moved into finally from catch');
28 pass('Moved into finally from catch');
30 ok($_ =~ /Die/, 'Error text as expected');
36 pass('Moved into finally block when try throws an exception and we have no catch block');
42 pass('First finally clause run');
44 pass('Second finally clause run');
51 fail("errors reported: @_");
53 pass("no error reported") ;
60 is_deeply(\@_, [ "Die\n" ], "finally got passed the exception");
71 pass("finally called");
77 is($_, "foo", "not localized in try");
82 is(scalar(@_), 0, "nothing in \@_ (finally)");
83 is($_, "foo", "\$_ not localized (finally)");
85 is($_, "foo", "same afterwards");
89 is($_, "foo", "not localized in try");
93 is($_[0], "bar\n", "error in \@_ (catch)");
94 is($_, "bar\n", "error in \$_ (catch)");
97 is(scalar(@_), 1, "error in \@_ (finally)");
98 is($_[0], "bar\n", "error in \@_ (finally)");
99 is($_, "foo", "\$_ not localized (finally)");
101 is($_, "foo", "same afterwards");
105 local $SIG{__WARN__} = sub {
106 $_[0] =~ /\QExecution of finally() block CODE(0x\E.+\Q) resulted in an exception/
121 is( scalar @warnings, 2, 'warnings from both fatal finally blocks' );
123 my @originals = sort map { $_ =~ /Original exception text follows:\n\n(.+)/s } @warnings;
125 like $originals[0], qr/fin 1 at/, 'First warning contains original exception';
126 like $originals[1], qr/fin 3 at/, 'Second warning contains original exception';
133 pass('before skip in try');
140 ok $finally, 'finally ran';