Change 32988 by [EMAIL PROTECTED] on 2008/01/17 11:31:38
Generate the warnings masks programatically.
Get the correct line number when reporting errors from &check_bits.
Affected files ...
... //depot/perl/t/op/caller.t#17 edit
Differences ...
==== //depot/perl/t/op/caller.t#17 (text) ====
Index: perl/t/op/caller.t
--- perl/t/op/caller.t#16~31393~ 2007-06-15 14:21:25.000000000 -0700
+++ perl/t/op/caller.t 2008-01-17 03:31:38.000000000 -0800
@@ -77,6 +77,7 @@
sub check_bits
{
+ local $Level = $Level + 2;
my ($got, $exp, $desc) = @_;
if (! ok($got eq $exp, $desc)) {
diag(' got: ' . show_bits($got));
@@ -90,22 +91,32 @@
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');
}
End of Patch.