diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-11-21 00:06:23 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-11-21 00:32:32 -0800 |
commit | 08f1b312e5e140a046594c5755039b96a41048ae (patch) | |
tree | 25cc26180d97dda7efaa761d3bdb19ea28ca8a94 /ext | |
parent | 799fd3b94fb5c431b24ee141e32a0b09d56f303c (diff) | |
download | perl-08f1b312e5e140a046594c5755039b96a41048ae.tar.gz |
Make newCONSTSUB use the right warning scope.
newCONSTSUB uses the compile-time warning hints, instead of the run-
time hints. This means that
use warnings;
BEGIN {
no warnings;
some_XS_function_that_calls_new_CONSTSUB();
}
may trigger a redefinition warning, whereas it should be analogous to
use warnings;
BEGIN {
no warnings;
*foo = \&bar;
}
which does not warn.
newCONSTSUB localises PL_curcop and sets it to &PL_compiling. When it
does that, it needs to copy the hints over.
Running tests inside eval is not reliable without a test count, so I
added one.
Diffstat (limited to 'ext')
-rw-r--r-- | ext/XS-APItest/t/newCONSTSUB.t | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/ext/XS-APItest/t/newCONSTSUB.t b/ext/XS-APItest/t/newCONSTSUB.t index 4a2edd62ab..286f9a2375 100644 --- a/ext/XS-APItest/t/newCONSTSUB.t +++ b/ext/XS-APItest/t/newCONSTSUB.t @@ -4,7 +4,7 @@ use strict; use warnings; use utf8; use open qw( :utf8 :std ); -use Test::More "no_plan"; +use Test::More tests => 9; use XS::APItest; @@ -22,3 +22,14 @@ ok !$::{"\x{30cb}"}, "...but not the right one"; ok $const, "newCONSTSUB_flags generates the constant,"; ok *{$glob}{CODE}, "..and the glob,"; ok $::{"\x{30cd}"}, "...the right one!"; + +eval q{ + BEGIN { + no warnings; + my $w; + local $SIG{__WARN__} = sub { $w .= shift }; + *foo = sub(){123}; + newCONSTSUB_type(\%::, "foo", 0, 1); + is $w, undef, 'newCONSTSUB uses calling scope for redefinition warnings'; + } +}; |