summaryrefslogtreecommitdiff
path: root/t/op/die_keeperr.t
diff options
context:
space:
mode:
authorZefram <zefram@fysh.org>2013-04-23 10:30:46 -0400
committerRicardo Signes <rjbs@cpan.org>2013-04-24 10:13:54 -0400
commitfc941f37b0048ca24b67f61973e6b9f50f9f908f (patch)
tree8c29bb37e45f7da55ffce1b57598267c346868a1 /t/op/die_keeperr.t
parentf321be7e68d63f48424096568e313ccad2b06211 (diff)
downloadperl-fc941f37b0048ca24b67f61973e6b9f50f9f908f.tar.gz
move Perl_ck_warner() before unwind [perl #113794]
Indeed. The Perl_ck_warner() call in die_unwind() used to happen before unwinding, so would be affected by the lexical warning state at the die() site. Now it happens after unwinding, so takes the lexical warning state at the catching site. I don't have a clear idea of which behaviour is more correct. t/op/die_keeperr.t, which was introduced as part of my exception handling changes, is actually testing for the catching-site criterion, but that's not asserting that the criterion should be that. The documentation speaks of "no warnings 'misc'", but doesn't say which lexical scope matters. Assuming we want to revert this change, the easy fix is to move the conditional Perl_ck_warner() back to before unwinding. A more difficult way would be to determine the disposition of the warning before unwinding and then warn in the required manner after unwinding. I see no compelling reason to warn after unwinding rather than before, so just moving the warning code should be fine. Note from the committer: This patch was supplied by Zefram in https://rt.perl.org/rt3/Ticket/Display.html?id=113794#txn-1204749 with a note that some extra work was required for ext/XS-APItest/t/call.t before the job was done. Ricardo Signes applied this patch and followed Zefram's lead in patching ext/XS-APItest/t/call.t without being 100% certain that this was what was meant. This commit was then submitted for review.
Diffstat (limited to 't/op/die_keeperr.t')
-rw-r--r--t/op/die_keeperr.t35
1 files changed, 33 insertions, 2 deletions
diff --git a/t/op/die_keeperr.t b/t/op/die_keeperr.t
index 9b41cb5935..083bd5d121 100644
--- a/t/op/die_keeperr.t
+++ b/t/op/die_keeperr.t
@@ -3,7 +3,7 @@
BEGIN {
chdir 't' if -d 't';
require 'test.pl';
- plan(20);
+ plan(24);
}
sub End::DESTROY { $_[0]->() }
@@ -31,14 +31,45 @@ foreach my $inx ("", "aabbcc\n", [qw(aa bb cc)]) {
no warnings "misc";
my $warn = "";
local $SIG{__WARN__} = sub { $warn .= $_[0] };
- { my $e = end { die "aa\n"; }; }
+ { my $e = end { no warnings "misc"; die "aa\n"; }; }
is $warn, "";
}
{
+ no warnings "misc";
+ my $warn = "";
+ local $SIG{__WARN__} = sub { $warn .= $_[0] };
+ { my $e = end { use warnings "misc"; die "aa\n"; }; }
+ is $warn, "\t(in cleanup) aa\n";
+}
+
+{
my $warn = "";
local $SIG{__WARN__} = sub { $warn .= $_[0] };
{ my $e = end { no warnings "misc"; die "aa\n"; }; }
+ is $warn, "";
+}
+
+{
+ my $warn = "";
+ local $SIG{__WARN__} = sub { $warn .= $_[0] };
+ { my $e = end { use warnings "misc"; die "aa\n"; }; }
+ is $warn, "\t(in cleanup) aa\n";
+}
+
+{
+ use warnings "misc";
+ my $warn = "";
+ local $SIG{__WARN__} = sub { $warn .= $_[0] };
+ { my $e = end { no warnings "misc"; die "aa\n"; }; }
+ is $warn, "";
+}
+
+{
+ use warnings "misc";
+ my $warn = "";
+ local $SIG{__WARN__} = sub { $warn .= $_[0] };
+ { my $e = end { use warnings "misc"; die "aa\n"; }; }
is $warn, "\t(in cleanup) aa\n";
}