Commit | Line | Data |
130617d9 |
1 | use strict; |
2 | use warnings; |
255d6d8b |
3 | use Test::More tests => 3; |
130617d9 |
4 | use Try::Tiny; |
5 | |
6 | { |
7 | package WithCatch; |
8 | use Try::Tiny; |
9 | |
10 | sub DESTROY { |
11 | try {} |
12 | catch {}; |
13 | return; |
14 | } |
15 | } |
16 | |
17 | { |
18 | package WithFinally; |
19 | use Try::Tiny; |
20 | |
80352025 |
21 | our $_in_destroy; |
130617d9 |
22 | sub DESTROY { |
80352025 |
23 | local $_in_destroy = 1; |
130617d9 |
24 | try {} |
25 | finally {}; |
26 | return; |
27 | } |
28 | } |
29 | |
130617d9 |
30 | try { |
31 | my $pid = fork; |
32 | unless ($pid) { |
33 | my $o = bless {}, 'WithCatch'; |
34 | $SIG{__DIE__} = sub { |
35 | exit 1 |
36 | if $_[0] =~ /A try\(\) may not be followed by multiple catch\(\) blocks/; |
37 | exit 2; |
38 | }; |
39 | exit 0; |
40 | } |
41 | waitpid $pid, 0; |
42 | is $?, 0, 'nested try in cleanup after fork does not maintain outer catch block'; |
43 | } |
44 | catch {}; |
45 | |
46 | try { |
47 | my $pid = fork; |
48 | unless ($pid) { |
49 | my $o = bless {}, 'WithFinally'; |
50 | exit 0; |
51 | } |
52 | waitpid $pid, 0; |
53 | is $?, 0, 'nested try in cleanup after fork does not maintain outer finally block'; |
54 | } |
80352025 |
55 | finally { exit 1 if $WithFinally::_in_destroy }; |
130617d9 |
56 | |
255d6d8b |
57 | pass("Didn't just exit"); |