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