This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix for perl #112316: Wrong behavior regarding labels with same prefix
[perl5.git] / t / op / die_keeperr.t
CommitLineData
7ce09284
Z
1#!perl -w
2
3BEGIN {
4 chdir 't' if -d 't';
5 require 'test.pl';
6 plan(20);
7}
8
9sub End::DESTROY { $_[0]->() }
10
11sub end(&) {
12 my($c) = @_;
13 return bless(sub { $c->() }, "End");
14}
15
16foreach 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
451;