sub check_bits
{
+ local $Level = $Level + 2;
my ($got, $exp, $desc) = @_;
if (! ok($got eq $exp, $desc)) {
diag(' got: ' . show_bits($got));
check_bits( (caller(0))[9], $w, "warnings match caller ($id)");
}
-# NB : extend the warning mask values below when new warnings are added
{
no warnings;
+ # Build the warnings mask dynamically
+ my ($default, $registered);
+ BEGIN {
+ for my $i (0..$warnings::LAST_BIT/2 - 1) {
+ vec($default, $i, 2) = 1;
+ }
+ $registered = $default;
+ vec($registered, $warnings::LAST_BIT/2, 2) = 1;
+ }
BEGIN { check_bits( ${^WARNING_BITS}, "\0" x 12, 'all bits off via "no warnings"' ) }
testwarn("\0" x 12, 'no bits');
use warnings;
- BEGIN { check_bits( ${^WARNING_BITS}, "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x05", 'default bits on via "use warnings"' ); }
- BEGIN { testwarn("\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x05", 'all'); }
+ BEGIN { check_bits( ${^WARNING_BITS}, $default,
+ 'default bits on via "use warnings"' ); }
+ BEGIN { testwarn($default, 'all'); }
# run-time :
# the warning mask has been extended by warnings::register
- testwarn("\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15", 'ahead of w::r');
+ testwarn($registered, 'ahead of w::r');
use warnings::register;
- BEGIN { check_bits( ${^WARNING_BITS}, "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15", 'warning bits on via "use warnings::register"' ) }
- testwarn("\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15", 'following w::r');
+ BEGIN { check_bits( ${^WARNING_BITS}, $registered,
+ 'warning bits on via "use warnings::register"' ) }
+ testwarn($registered, 'following w::r');
}