Check lexical warnings functionality
TODO
check that the warning hierarchy works.
__END__
# check illegal category is caught
use warnings 'this-should-never-be-a-warning-category' ;
EXPECT
Unknown warnings category 'this-should-never-be-a-warning-category' at .../warnings.pm line xxx.
warnings::import called at - line 3 character 1.
BEGIN called at - line 3 character 1.
########
# Check runtime scope of pragma
use warnings 'uninitialized' ;
do {
no warnings ;
my $b ; chop $b ;
};
my $b ; chop $b ;
EXPECT
Use of uninitialized value $b in chop at - line 8 character 9.
########
# Check runtime scope of pragma
no warnings ;
do {
use warnings 'uninitialized' ;
my $b ; chop $b ;
};
my $b ; chop $b ;
EXPECT
Use of uninitialized value $b in chop at - line 6 character 13.
########
# Check runtime scope of pragma
no warnings ;
do {
use warnings 'uninitialized' ;
$a = sub { my $b ; chop $b ; }
};
&$a() ;
EXPECT
Use of uninitialized value $b in chop at - line 6 character 24.
main::__ANON__ called at - line 8 character 1.
########
-w
no warnings 'reserved' ;
foo.bar;
EXPECT
Unknown bare word foo at - line 3, at end of line
Unknown bare word bar at - line 3, at end of line
Bareword "foo" not allowed while "strict subs" in use at - line 3 character 1.
########
# Check scope of pragma with eval
use warnings;
do {
no warnings ;
try {
my $b ; chop $b ;
}; print $^STDERR, $^EVAL_ERROR ;
my $b ; chop $b ;
};
EXPECT
########
# Check scope of pragma with eval
use warnings;
do {
no warnings ;
try {
use warnings 'uninitialized' ;
my $b ; chop $b ;
}; print $^STDERR, $^EVAL_ERROR ;
my $b ; chop $b ;
};
EXPECT
Use of uninitialized value $b in chop at - line 8 character 17.
(eval) called at - line 6 character 5.
########
# Check scope of pragma with eval
no warnings;
do {
use warnings 'uninitialized' ;
try {
my $b ; chop $b ;
}; print $^STDERR, $^EVAL_ERROR ;
my $b ; chop $b ;
};
EXPECT
Use of uninitialized value $b in chop at - line 7 character 17.
(eval) called at - line 6 character 5.
Use of uninitialized value $b in chop at - line 9 character 13.
########
# Check scope of pragma with eval
no warnings;
do {
use warnings 'uninitialized' ;
try {
no warnings ;
my $b ; chop $b ;
}; print $^STDERR, $^EVAL_ERROR ;
my $b ; chop $b ;
};
EXPECT
Use of uninitialized value $b in chop at - line 10 character 13.
########
# Check scope of pragma with eval
use warnings;
do {
no warnings ;
eval '
my $b ; chop $b ;
'; print $^STDERR, $^EVAL_ERROR ;
my $b ; chop $b ;
};
EXPECT
########
# Check scope of pragma with eval
use warnings;
do {
no warnings ;
eval q[
use warnings 'uninitialized' ;
my $b ; chop $b ;
]; print $^STDERR, $^EVAL_ERROR;
my $b ; chop $b ;
};
EXPECT
Use of uninitialized value $b in chop at (eval 1) line 3 character 58.
(eval) called at - line 6 character 5.
########
# Check scope of pragma with eval
no warnings;
do {
use warnings 'uninitialized' ;
eval '
my $b ; chop $b ;
'; print $^STDERR, $^EVAL_ERROR ;
my $b ; chop $b ;
};
EXPECT
Use of uninitialized value $b in chop at (eval 1) line 2 character 18.
(eval) called at - line 6 character 5.
Use of uninitialized value $b in chop at - line 9 character 13.
########
# Check scope of pragma with eval
no warnings;
do {
use warnings 'uninitialized' ;
eval '
no warnings ;
my $b ; chop $b ;
'; print $^STDERR, $^EVAL_ERROR ;
my $b ; chop $b ;
};
EXPECT
Use of uninitialized value $b in chop at - line 10 character 13.