diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-01-26 20:43:17 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-01-26 20:43:17 -0800 |
commit | 7e4f04509c6d4e8d2ed0e31eaf59004e5c930b39 (patch) | |
tree | 9a582799ceb6695192fb8324f9b7684a759767cc /t | |
parent | cc88c9aaa7ecb8334614c515caf0da2d5538403b (diff) | |
download | perl-7e4f04509c6d4e8d2ed0e31eaf59004e5c930b39.tar.gz |
Allow ${^WARNING_BITS} to turn off lexical warnings
Various magical modules copy hints from one scope to another. But
copying ${^WARNING_BITS} doesn’t always copy the same hints. If lexi-
cal warnings are not on at all, ${^WARNING_BITS} returns a different
value depending on the current value of $^W. Setting ${^WARNING_BITS}
to its own value when $^W is true will stop $^W from being able to
control the warnings in the current compilation scope. Setting
${^WARNING_BITS} to its own value when $^W is false causes even
default warnings to be suppressed.
This commit makes undef a special value that represents the default
state, in which $^W controls warnings.
Diffstat (limited to 't')
-rw-r--r-- | t/comp/hints.t | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/t/comp/hints.t b/t/comp/hints.t index 835e1e258f..8401ec9436 100644 --- a/t/comp/hints.t +++ b/t/comp/hints.t @@ -6,7 +6,7 @@ BEGIN { @INC = qw(. ../lib); } -BEGIN { print "1..28\n"; } +BEGIN { print "1..29\n"; } BEGIN { print "not " if exists $^H{foo}; print "ok 1 - \$^H{foo} doesn't exist initially\n"; @@ -198,6 +198,24 @@ print "ok 26 - no crash when cloning a tied hint hash\n"; print "# got: $w" if $w; } +# Setting ${^WARNING_HINTS} to its own value should not change things. +{ + my $w; + local $SIG{__WARN__} = sub { $w++ }; + BEGIN { + # should have no effect: + my $x = ${^WARNING_BITS}; + ${^WARNING_BITS} = $x; + } + { + local $^W = 1; + () = 1 + undef; + } + print "# ", $w//'no', " warnings\nnot " unless $w == 1; + print "ok 28 - ", + "setting \${^WARNING_BITS} to its own value has no effect\n"; +} + # Add new tests above this require, in case it fails. require './test.pl'; @@ -208,7 +226,7 @@ my $result = runperl( stderr => 1 ); print "not " if length $result; -print "ok 28 - double-freeing hints hash\n"; +print "ok 29 - double-freeing hints hash\n"; print "# got: $result\n" if length $result; __END__ |