Commit | Line | Data |
3233f09d |
1 | use warnings; |
2 | use strict; |
3 | |
4 | use Test::More; |
5 | use Exception::Guaranteed; |
6 | |
7 | use lib 't'; |
8 | use __SelfDestruct; |
9 | |
10 | my $dummy = 0; |
11 | |
12 | my $err; |
13 | $SIG{__DIE__} = sub { $err = shift }; |
14 | |
15 | my $final_fn = __FILE__; |
16 | my $final_ln = __LINE__ + 1; |
17 | __SelfDestruct->spawn_n_kill( sub { guarantee_exception { die 'Final untrapped exception' } } ); |
18 | |
19 | while ($dummy < 2**31) { |
20 | $dummy++; |
21 | } |
22 | fail ('Should never reach here :('); |
23 | |
24 | END { |
25 | diag( ($dummy||0) . " inc-ops executed before kill-signal delivery\n" ); |
26 | |
27 | is ( |
28 | $err, |
29 | "Final untrapped exception at $final_fn line $final_ln.\n", |
30 | 'Untrapped DESTROY exception correctly propagated', |
31 | ); |
32 | |
33 | my $ok; |
34 | |
35 | # on win32 the $? is *not* set to 255, not sure why :( |
36 | if ($^O eq 'MSWin32') { |
37 | cmp_ok ($?, '!=', 0, '$? correctly set to a non-0 value under windows' ) |
38 | and $ok = 1; |
39 | } |
40 | |
41 | { |
42 | local $TODO = 'Win32 buggery - $? is unstable for some reason' |
43 | if $^O eq 'MSWin32'; |
44 | |
45 | # check, and then change $? set by the last die |
46 | is ($?, 255, '$? correctly set by untrapped die()') # $? in END{} is *NOT* 16bit |
47 | and $ok = 1; |
48 | } |
49 | |
50 | $? = 0 if $ok; # adjust the exit to "passing" (0) IFF the test didn't fail |
51 | |
52 | done_testing; |
53 | } |