Commit | Line | Data |
---|---|---|
7ce09284 Z |
1 | #!perl -w |
2 | ||
3 | BEGIN { | |
4 | chdir 't' if -d 't'; | |
5 | require 'test.pl'; | |
6 | plan(20); | |
7 | } | |
8 | ||
9 | sub End::DESTROY { $_[0]->() } | |
10 | ||
11 | sub end(&) { | |
12 | my($c) = @_; | |
13 | return bless(sub { $c->() }, "End"); | |
14 | } | |
15 | ||
16 | foreach my $inx ("", "aabbcc\n", [qw(aa bb cc)]) { | |
17 | foreach my $outx ("", "xxyyzz\n", [qw(xx yy zz)]) { | |
18 | my $warn = ""; | |
19 | local $SIG{__WARN__} = sub { $warn .= $_[0] }; | |
20 | { | |
21 | $@ = $outx; | |
22 | my $e = end { die $inx if $inx }; | |
23 | } | |
24 | ok ref($@) eq ref($outx) && $@ eq $outx; | |
25 | $warn =~ s/ at [^\n]*\n\z//; | |
26 | is $warn, $inx ? "\t(in cleanup) $inx" : ""; | |
27 | } | |
28 | } | |
29 | ||
30 | { | |
31 | no warnings "misc"; | |
32 | my $warn = ""; | |
33 | local $SIG{__WARN__} = sub { $warn .= $_[0] }; | |
34 | { my $e = end { die "aa\n"; }; } | |
35 | is $warn, ""; | |
36 | } | |
37 | ||
38 | { | |
39 | my $warn = ""; | |
40 | local $SIG{__WARN__} = sub { $warn .= $_[0] }; | |
41 | { my $e = end { no warnings "misc"; die "aa\n"; }; } | |
42 | is $warn, "\t(in cleanup) aa\n"; | |
43 | } | |
44 | ||
45 | 1; |