X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fop%2Fcaller.t;h=c97191b14a7edf9ac2220555146d72034f5bc673;hb=75b6c4caab1abb3506eab9e8e512c69bbeb1c49f;hp=751a161de2ade22f2cd1c71f4a63f95cfea2b671;hpb=8fa7688f7865696bdfa78bc12d4ffb78bd1d6103;p=p5sagit%2Fp5-mst-13.2.git diff --git a/t/op/caller.t b/t/op/caller.t index 751a161..c97191b 100644 --- a/t/op/caller.t +++ b/t/op/caller.t @@ -5,10 +5,9 @@ BEGIN { chdir 't' if -d 't'; @INC = '../lib'; require './test.pl'; + plan( tests => 27 ); } -plan( tests => 20 ); - my @c; print "# Tests with caller(0)\n"; @@ -63,3 +62,26 @@ my $fooref2 = delete $::{foo2}; $fooref2 -> (); is( $c[3], "(unknown)", "unknown subroutine name" ); ok( $c[4], "hasargs true with unknown sub" ); + +# See if caller() returns the correct warning mask + +sub testwarn { + my $w = shift; + is( (caller(0))[9], $w, "warnings"); +} + +# NB : extend the warning mask values below when new warnings are added +{ + no warnings; + BEGIN { is( ${^WARNING_BITS}, "\0" x 12, 'warning bits' ) } + testwarn("\0" x 12); + use warnings; + BEGIN { is( ${^WARNING_BITS}, "U" x 12, 'warning bits' ) } + BEGIN { testwarn("U" x 12); } + # run-time : + # the warning mask has been extended by warnings::register + testwarn("UUUUUUUUUUUU\001"); + use warnings::register; + BEGIN { is( ${^WARNING_BITS}, "UUUUUUUUUUUU\001", 'warning bits' ) } + testwarn("UUUUUUUUUUUU\001"); +}