309 lines
5.6 KiB
Plaintext
309 lines
5.6 KiB
Plaintext
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 - line 3
|
|
BEGIN failed--compilation aborted at - line 3.
|
|
########
|
|
|
|
# Check compile time scope of pragma
|
|
use warnings 'deprecated' ;
|
|
{
|
|
no warnings ;
|
|
1 if $a EQ $b ;
|
|
}
|
|
1 if $a EQ $b ;
|
|
EXPECT
|
|
Use of EQ is deprecated at - line 8.
|
|
########
|
|
|
|
# Check compile time scope of pragma
|
|
no warnings;
|
|
{
|
|
use warnings 'deprecated' ;
|
|
1 if $a EQ $b ;
|
|
}
|
|
1 if $a EQ $b ;
|
|
EXPECT
|
|
Use of EQ is deprecated at - line 6.
|
|
########
|
|
|
|
# Check runtime scope of pragma
|
|
use warnings 'uninitialized' ;
|
|
{
|
|
no warnings ;
|
|
my $b ; chop $b ;
|
|
}
|
|
my $b ; chop $b ;
|
|
EXPECT
|
|
Use of uninitialized value in scalar chop at - line 8.
|
|
########
|
|
|
|
# Check runtime scope of pragma
|
|
no warnings ;
|
|
{
|
|
use warnings 'uninitialized' ;
|
|
my $b ; chop $b ;
|
|
}
|
|
my $b ; chop $b ;
|
|
EXPECT
|
|
Use of uninitialized value in scalar chop at - line 6.
|
|
########
|
|
|
|
# Check runtime scope of pragma
|
|
no warnings ;
|
|
{
|
|
use warnings 'uninitialized' ;
|
|
$a = sub { my $b ; chop $b ; }
|
|
}
|
|
&$a ;
|
|
EXPECT
|
|
Use of uninitialized value in scalar chop at - line 6.
|
|
########
|
|
|
|
use warnings 'deprecated' ;
|
|
1 if $a EQ $b ;
|
|
EXPECT
|
|
Use of EQ is deprecated at - line 3.
|
|
########
|
|
|
|
--FILE-- abc
|
|
1 if $a EQ $b ;
|
|
1;
|
|
--FILE--
|
|
use warnings 'deprecated' ;
|
|
require "./abc";
|
|
EXPECT
|
|
|
|
########
|
|
|
|
--FILE-- abc
|
|
use warnings 'deprecated' ;
|
|
1;
|
|
--FILE--
|
|
require "./abc";
|
|
1 if $a EQ $b ;
|
|
EXPECT
|
|
|
|
########
|
|
|
|
--FILE-- abc
|
|
use warnings 'deprecated' ;
|
|
1 if $a EQ $b ;
|
|
1;
|
|
--FILE--
|
|
use warnings 'uninitialized' ;
|
|
require "./abc";
|
|
my $a ; chop $a ;
|
|
EXPECT
|
|
Use of EQ is deprecated at ./abc line 2.
|
|
Use of uninitialized value in scalar chop at - line 3.
|
|
########
|
|
|
|
--FILE-- abc.pm
|
|
use warnings 'deprecated' ;
|
|
1 if $a EQ $b ;
|
|
1;
|
|
--FILE--
|
|
use warnings 'uninitialized' ;
|
|
use abc;
|
|
my $a ; chop $a ;
|
|
EXPECT
|
|
Use of EQ is deprecated at abc.pm line 2.
|
|
Use of uninitialized value in scalar chop at - line 3.
|
|
########
|
|
|
|
# Check scope of pragma with eval
|
|
no warnings ;
|
|
eval {
|
|
my $b ; chop $b ;
|
|
}; print STDERR $@ ;
|
|
my $b ; chop $b ;
|
|
EXPECT
|
|
|
|
########
|
|
|
|
# Check scope of pragma with eval
|
|
no warnings ;
|
|
eval {
|
|
use warnings 'uninitialized' ;
|
|
my $b ; chop $b ;
|
|
}; print STDERR $@ ;
|
|
my $b ; chop $b ;
|
|
EXPECT
|
|
Use of uninitialized value in scalar chop at - line 6.
|
|
########
|
|
|
|
# Check scope of pragma with eval
|
|
use warnings 'uninitialized' ;
|
|
eval {
|
|
my $b ; chop $b ;
|
|
}; print STDERR $@ ;
|
|
my $b ; chop $b ;
|
|
EXPECT
|
|
Use of uninitialized value in scalar chop at - line 5.
|
|
Use of uninitialized value in scalar chop at - line 7.
|
|
########
|
|
|
|
# Check scope of pragma with eval
|
|
use warnings 'uninitialized' ;
|
|
eval {
|
|
no warnings ;
|
|
my $b ; chop $b ;
|
|
}; print STDERR $@ ;
|
|
my $b ; chop $b ;
|
|
EXPECT
|
|
Use of uninitialized value in scalar chop at - line 8.
|
|
########
|
|
|
|
# Check scope of pragma with eval
|
|
no warnings ;
|
|
eval {
|
|
1 if $a EQ $b ;
|
|
}; print STDERR $@ ;
|
|
1 if $a EQ $b ;
|
|
EXPECT
|
|
|
|
########
|
|
|
|
# Check scope of pragma with eval
|
|
no warnings ;
|
|
eval {
|
|
use warnings 'deprecated' ;
|
|
1 if $a EQ $b ;
|
|
}; print STDERR $@ ;
|
|
1 if $a EQ $b ;
|
|
EXPECT
|
|
Use of EQ is deprecated at - line 6.
|
|
########
|
|
|
|
# Check scope of pragma with eval
|
|
use warnings 'deprecated' ;
|
|
eval {
|
|
1 if $a EQ $b ;
|
|
}; print STDERR $@ ;
|
|
1 if $a EQ $b ;
|
|
EXPECT
|
|
Use of EQ is deprecated at - line 5.
|
|
Use of EQ is deprecated at - line 7.
|
|
########
|
|
|
|
# Check scope of pragma with eval
|
|
use warnings 'deprecated' ;
|
|
eval {
|
|
no warnings ;
|
|
1 if $a EQ $b ;
|
|
}; print STDERR $@ ;
|
|
1 if $a EQ $b ;
|
|
EXPECT
|
|
Use of EQ is deprecated at - line 8.
|
|
########
|
|
|
|
# Check scope of pragma with eval
|
|
no warnings ;
|
|
eval '
|
|
my $b ; chop $b ;
|
|
'; print STDERR $@ ;
|
|
my $b ; chop $b ;
|
|
EXPECT
|
|
|
|
########
|
|
|
|
# Check scope of pragma with eval
|
|
no warnings ;
|
|
eval q[
|
|
use warnings 'uninitialized' ;
|
|
my $b ; chop $b ;
|
|
]; print STDERR $@;
|
|
my $b ; chop $b ;
|
|
EXPECT
|
|
Use of uninitialized value in scalar chop at (eval 1) line 3.
|
|
########
|
|
|
|
# Check scope of pragma with eval
|
|
use warnings 'uninitialized' ;
|
|
eval '
|
|
my $b ; chop $b ;
|
|
'; print STDERR $@ ;
|
|
my $b ; chop $b ;
|
|
EXPECT
|
|
Use of uninitialized value in scalar chop at (eval 1) line 2.
|
|
Use of uninitialized value in scalar chop at - line 7.
|
|
########
|
|
|
|
# Check scope of pragma with eval
|
|
use warnings 'uninitialized' ;
|
|
eval '
|
|
no warnings ;
|
|
my $b ; chop $b ;
|
|
'; print STDERR $@ ;
|
|
my $b ; chop $b ;
|
|
EXPECT
|
|
Use of uninitialized value in scalar chop at - line 8.
|
|
########
|
|
|
|
# Check scope of pragma with eval
|
|
no warnings ;
|
|
eval '
|
|
1 if $a EQ $b ;
|
|
'; print STDERR $@ ;
|
|
1 if $a EQ $b ;
|
|
EXPECT
|
|
|
|
########
|
|
|
|
# Check scope of pragma with eval
|
|
no warnings ;
|
|
eval q[
|
|
use warnings 'deprecated' ;
|
|
1 if $a EQ $b ;
|
|
]; print STDERR $@;
|
|
1 if $a EQ $b ;
|
|
EXPECT
|
|
Use of EQ is deprecated at (eval 1) line 3.
|
|
########
|
|
|
|
# Check scope of pragma with eval
|
|
use warnings 'deprecated' ;
|
|
eval '
|
|
1 if $a EQ $b ;
|
|
'; print STDERR $@;
|
|
1 if $a EQ $b ;
|
|
EXPECT
|
|
Use of EQ is deprecated at - line 7.
|
|
Use of EQ is deprecated at (eval 1) line 2.
|
|
########
|
|
|
|
# Check scope of pragma with eval
|
|
use warnings 'deprecated' ;
|
|
eval '
|
|
no warnings ;
|
|
1 if $a EQ $b ;
|
|
'; print STDERR $@;
|
|
1 if $a EQ $b ;
|
|
EXPECT
|
|
Use of EQ is deprecated at - line 8.
|
|
########
|
|
|
|
# Check the additive nature of the pragma
|
|
1 if $a EQ $b ;
|
|
my $a ; chop $a ;
|
|
use warnings 'deprecated' ;
|
|
1 if $a EQ $b ;
|
|
my $b ; chop $b ;
|
|
use warnings 'uninitialized' ;
|
|
my $c ; chop $c ;
|
|
no warnings 'deprecated' ;
|
|
1 if $a EQ $b ;
|
|
EXPECT
|
|
Use of EQ is deprecated at - line 6.
|
|
Use of uninitialized value in scalar chop at - line 9.
|
|
Use of uninitialized value in string eq at - line 11.
|
|
Use of uninitialized value in string eq at - line 11.
|