diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 2000-02-20 22:58:09 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 2000-02-20 22:58:09 +0000 |
commit | e476b1b5c29f354cf8dad61a9fc6d855bdfb5b7d (patch) | |
tree | 15dd81e8f41d5ccfb48b2e0d3b564ee0d7cf6458 /t/pragma | |
parent | 635bbe87639b3a9ff9c900336f8f6c30e3d557b9 (diff) | |
download | perl-e476b1b5c29f354cf8dad61a9fc6d855bdfb5b7d.tar.gz |
lexical warnings update, ability to inspect bitmask in calling
scope, among other things (from Paul Marquess)
p4raw-id: //depot/perl@5170
Diffstat (limited to 't/pragma')
-rw-r--r-- | t/pragma/warn/op | 62 | ||||
-rw-r--r-- | t/pragma/warn/pp | 28 | ||||
-rw-r--r-- | t/pragma/warn/pp_ctl | 36 | ||||
-rw-r--r-- | t/pragma/warn/pp_hot | 12 | ||||
-rw-r--r-- | t/pragma/warn/regcomp | 37 | ||||
-rw-r--r-- | t/pragma/warn/regexec | 8 | ||||
-rw-r--r-- | t/pragma/warn/sv | 8 | ||||
-rw-r--r-- | t/pragma/warn/toke | 28 |
8 files changed, 111 insertions, 108 deletions
diff --git a/t/pragma/warn/op b/t/pragma/warn/op index 9fd418e5bc..d70a333bbc 100644 --- a/t/pragma/warn/op +++ b/t/pragma/warn/op @@ -59,7 +59,7 @@ local $a, $b = (1,2); Bareword found in conditional at -e line 1. - use warnings 'syntax'; my $x = print(ABC || 1); + use warnings 'bareword'; my $x = print(ABC || 1); Value of %s may be \"0\"; use \"defined\" $x = 1 if $x = <FH> ; @@ -117,16 +117,16 @@ __END__ # op.c -use warnings 'unsafe' ; +use warnings 'misc' ; my $x ; my $x ; -no warnings 'unsafe' ; +no warnings 'misc' ; my $x ; EXPECT "my" variable $x masks earlier declaration in same scope at - line 4. ######## # op.c -use warnings 'unsafe' ; +use warnings 'closure' ; sub x { my $x; sub y { @@ -137,7 +137,7 @@ EXPECT Variable "$x" will not stay shared at - line 7. ######## # op.c -no warnings 'unsafe' ; +no warnings 'closure' ; sub x { my $x; sub y { @@ -148,7 +148,7 @@ EXPECT ######## # op.c -use warnings 'unsafe' ; +use warnings 'closure' ; sub x { my $x; sub y { @@ -159,7 +159,7 @@ EXPECT Variable "$x" may be unavailable at - line 6. ######## # op.c -no warnings 'unsafe' ; +no warnings 'closure' ; sub x { my $x; sub y { @@ -559,7 +559,7 @@ Useless use of a constant in void context at - line 4. ######## # op.c BEGIN{ $ENV{PERL_DESTRUCT_LEVEL} = 0 unless $ENV{PERL_DESTRUCT_LEVEL} > 3; } # known scalar leak -use warnings 'unsafe' ; +use warnings 'misc' ; my $a ; my @a = () ; my %a = () ; my $b = \@a ; my $c = \%a ; @a =~ /abc/ ; @a =~ s/a/b/ ; @@ -574,7 +574,7 @@ my $a ; my @a = () ; my %a = () ; my $b = \@a ; my $c = \%a ; %$c =~ s/a/b/ ; %$c =~ tr/a/b/ ; { -no warnings 'unsafe' ; +no warnings 'misc' ; my $a ; my @a = () ; my %a = () ; my $b = \@a ; my $c = \%a ; @a =~ /abc/ ; @a =~ s/a/b/ ; @@ -622,9 +622,9 @@ EXPECT Parentheses missing around "local" list at - line 3. ######## # op.c -use warnings 'syntax' ; +use warnings 'bareword' ; print (ABC || 1) ; -no warnings 'syntax' ; +no warnings 'bareword' ; print (ABC || 1) ; EXPECT Bareword found in conditional at - line 3. @@ -633,54 +633,54 @@ Bareword found in conditional at - line 3. --FILE-- # op.c -use warnings 'unsafe' ; +use warnings 'misc' ; open FH, "<abc" ; $x = 1 if $x = <FH> ; -no warnings 'unsafe' ; +no warnings 'misc' ; $x = 1 if $x = <FH> ; EXPECT Value of <HANDLE> construct can be "0"; test with defined() at - line 4. ######## # op.c -use warnings 'unsafe' ; +use warnings 'misc' ; opendir FH, "." ; $x = 1 if $x = readdir FH ; -no warnings 'unsafe' ; +no warnings 'misc' ; $x = 1 if $x = readdir FH ; closedir FH ; EXPECT Value of readdir() operator can be "0"; test with defined() at - line 4. ######## # op.c -use warnings 'unsafe' ; +use warnings 'misc' ; $x = 1 if $x = <*> ; -no warnings 'unsafe' ; +no warnings 'misc' ; $x = 1 if $x = <*> ; EXPECT Value of glob construct can be "0"; test with defined() at - line 3. ######## # op.c -use warnings 'unsafe' ; +use warnings 'misc' ; %a = (1,2,3,4) ; $x = 1 if $x = each %a ; -no warnings 'unsafe' ; +no warnings 'misc' ; $x = 1 if $x = each %a ; EXPECT Value of each() operator can be "0"; test with defined() at - line 4. ######## # op.c -use warnings 'unsafe' ; +use warnings 'misc' ; $x = 1 while $x = <*> and 0 ; -no warnings 'unsafe' ; +no warnings 'misc' ; $x = 1 while $x = <*> and 0 ; EXPECT Value of glob construct can be "0"; test with defined() at - line 3. ######## # op.c -use warnings 'unsafe' ; +use warnings 'misc' ; opendir FH, "." ; $x = 1 while $x = readdir FH and 0 ; -no warnings 'unsafe' ; +no warnings 'misc' ; $x = 1 while $x = readdir FH and 0 ; closedir FH ; EXPECT @@ -717,17 +717,17 @@ EXPECT Format FRED redefined at - line 5. ######## # op.c -use warnings 'syntax' ; +use warnings 'deprecated' ; push FRED; -no warnings 'syntax' ; +no warnings 'deprecated' ; push FRED; EXPECT Array @FRED missing the @ in argument 1 of push() at - line 3. ######## # op.c -use warnings 'syntax' ; +use warnings 'deprecated' ; @a = keys FRED ; -no warnings 'syntax' ; +no warnings 'deprecated' ; @a = keys FRED ; EXPECT Hash %FRED missing the % in argument 1 of keys() at - line 3. @@ -779,10 +779,10 @@ $^W = 0 ; sub fred() ; sub fred($) {} { - no warnings 'unsafe' ; + no warnings 'prototype' ; sub Fred() ; sub Fred($) {} - use warnings 'unsafe' ; + use warnings 'prototype' ; sub freD() ; sub freD($) {} } @@ -800,10 +800,10 @@ EXPECT /---/ should probably be written as "---" at - line 3. ######## # op.c [Perl_peep] -use warnings 'unsafe' ; +use warnings 'prototype' ; fred() ; sub fred ($$) {} -no warnings 'unsafe' ; +no warnings 'prototype' ; joe() ; sub joe ($$) {} EXPECT diff --git a/t/pragma/warn/pp b/t/pragma/warn/pp index 4c70fd5d6f..b392029767 100644 --- a/t/pragma/warn/pp +++ b/t/pragma/warn/pp @@ -1,7 +1,7 @@ pp.c TODO substr outside of string - $a = "ab" ; $a = substr($a, 4,5) + $a = "ab" ; $b = substr($a, 4,5) ; Attempt to use reference as lvalue in substr $a = "ab" ; $b = \$a ; substr($b, 1,1) = $b @@ -37,10 +37,10 @@ __END__ # pp.c use warnings 'substr' ; $a = "ab" ; -$a = substr($a, 4,5); +$b = substr($a, 4,5) ; no warnings 'substr' ; $a = "ab" ; -$a = substr($a, 4,5); +$b = substr($a, 4,5) ; EXPECT substr outside of string at - line 4. ######## @@ -61,23 +61,25 @@ EXPECT ######## # pp.c -use warnings 'unsafe' ; +use warnings 'misc' ; my $a = { 1,2,3}; -no warnings 'unsafe' ; +no warnings 'misc' ; my $b = { 1,2,3}; EXPECT Odd number of elements in hash assignment at - line 3. ######## # pp.c -use warnings 'unsafe' ; +use warnings 'pack' ; +use warnings 'unpack' ; my @a = unpack ("A,A", "22") ; my $a = pack ("A,A", 1,2) ; -no warnings 'unsafe' ; +no warnings 'pack' ; +no warnings 'unpack' ; my @b = unpack ("A,A", "22") ; my $b = pack ("A,A", 1,2) ; EXPECT -Invalid type in unpack: ',' at - line 3. -Invalid type in pack: ',' at - line 4. +Invalid type in unpack: ',' at - line 4. +Invalid type in pack: ',' at - line 5. ######## # pp.c use warnings 'uninitialized' ; @@ -89,18 +91,18 @@ EXPECT Use of uninitialized value in scalar dereference at - line 4. ######## # pp.c -use warnings 'unsafe' ; +use warnings 'pack' ; sub foo { my $a = "a"; return $a . $a++ . $a++ } my $a = pack("p", &foo) ; -no warnings 'unsafe' ; +no warnings 'pack' ; my $b = pack("p", &foo) ; EXPECT Attempt to pack pointer to temporary value at - line 4. ######## # pp.c -use warnings 'unsafe' ; +use warnings 'misc' ; bless \[], "" ; -no warnings 'unsafe' ; +no warnings 'misc' ; bless \[], "" ; EXPECT Explicit blessing to '' (assuming package main) at - line 3. diff --git a/t/pragma/warn/pp_ctl b/t/pragma/warn/pp_ctl index f61da1a8e1..0deccd35e2 100644 --- a/t/pragma/warn/pp_ctl +++ b/t/pragma/warn/pp_ctl @@ -81,14 +81,14 @@ EXPECT 1 ######## # pp_ctl.c -use warnings 'unsafe' ; +use warnings 'exiting' ; $_ = "abc" ; while ($i ++ == 0) { s/ab/last/e ; } -no warnings 'unsafe' ; +no warnings 'exiting' ; while ($i ++ == 0) { s/ab/last/e ; @@ -97,10 +97,10 @@ EXPECT Exiting substitution via last at - line 7. ######## # pp_ctl.c -use warnings 'unsafe' ; +use warnings 'exiting' ; sub fred { last } { fred() } -no warnings 'unsafe' ; +no warnings 'exiting' ; sub joe { last } { joe() } EXPECT @@ -108,35 +108,35 @@ Exiting subroutine via last at - line 3. ######## # pp_ctl.c { - eval "use warnings 'unsafe' ; last;" + eval "use warnings 'exiting' ; last;" } print STDERR $@ ; { - eval "no warnings 'unsafe' ;last;" + eval "no warnings 'exiting' ;last;" } print STDERR $@ ; EXPECT Exiting eval via last at (eval 1) line 1. ######## # pp_ctl.c -use warnings 'unsafe' ; +use warnings 'exiting' ; @a = (1,2) ; @b = sort { last } @a ; -no warnings 'unsafe' ; +no warnings 'exiting' ; @b = sort { last } @a ; EXPECT Exiting pseudo-block via last at - line 4. Can't "last" outside a loop block at - line 4. ######## # pp_ctl.c -use warnings 'unsafe' ; +use warnings 'exiting' ; $_ = "abc" ; fred: while ($i ++ == 0) { s/ab/last fred/e ; } -no warnings 'unsafe' ; +no warnings 'exiting' ; while ($i ++ == 0) { s/ab/last fred/e ; @@ -145,10 +145,10 @@ EXPECT Exiting substitution via last at - line 7. ######## # pp_ctl.c -use warnings 'unsafe' ; +use warnings 'exiting' ; sub fred { last joe } joe: { fred() } -no warnings 'unsafe' ; +no warnings 'exiting' ; sub Fred { last Joe } Joe: { Fred() } EXPECT @@ -156,19 +156,19 @@ Exiting subroutine via last at - line 3. ######## # pp_ctl.c joe: -{ eval "use warnings 'unsafe' ; last joe;" } +{ eval "use warnings 'exiting' ; last joe;" } print STDERR $@ ; Joe: -{ eval "no warnings 'unsafe' ; last Joe;" } +{ eval "no warnings 'exiting' ; last Joe;" } print STDERR $@ ; EXPECT Exiting eval via last at (eval 1) line 1. ######## # pp_ctl.c -use warnings 'unsafe' ; +use warnings 'exiting' ; @a = (1,2) ; fred: @b = sort { last fred } @a ; -no warnings 'unsafe' ; +no warnings 'exiting' ; Fred: @b = sort { last Fred } @a ; EXPECT Exiting pseudo-block via last at - line 4. @@ -198,7 +198,7 @@ fred() EXPECT ######## # pp_ctl.c -use warnings 'unsafe' ; +use warnings 'misc' ; package Foo; DESTROY { die "@{$_[0]} foo bar" } { bless ['A'], 'Foo' for 1..10 } @@ -208,7 +208,7 @@ EXPECT (in cleanup) B foo bar at - line 4. ######## # pp_ctl.c -no warnings 'unsafe' ; +no warnings 'misc' ; package Foo; DESTROY { die "@{$_[0]} foo bar" } { bless ['A'], 'Foo' for 1..10 } diff --git a/t/pragma/warn/pp_hot b/t/pragma/warn/pp_hot index 312f7da9b2..0cbbc439ad 100644 --- a/t/pragma/warn/pp_hot +++ b/t/pragma/warn/pp_hot @@ -114,17 +114,17 @@ EXPECT Use of uninitialized value in hash dereference at - line 4. ######## # pp_hot.c [pp_aassign] -use warnings 'unsafe' ; +use warnings 'misc' ; my %X ; %X = (1,2,3) ; -no warnings 'unsafe' ; +no warnings 'misc' ; my %Y ; %Y = (1,2,3) ; EXPECT Odd number of elements in hash assignment at - line 3. ######## # pp_hot.c [pp_aassign] -use warnings 'unsafe' ; +use warnings 'misc' ; my %X ; %X = [1 .. 3] ; -no warnings 'unsafe' ; +no warnings 'misc' ; my %Y ; %Y = [1 .. 3] ; EXPECT Reference found where even-sized list expected at - line 3. @@ -205,7 +205,7 @@ $b = sub EXPECT ######## # pp_hot.c [pp_concat] -use warnings 'misc'; +use warnings 'y2k'; use Config; BEGIN { unless ($Config{ccflags} =~ /Y2KWARN/) { @@ -219,7 +219,7 @@ $x = "19$yy\n"; $x = "19" . $yy . "\n"; $x = "319$yy\n"; $x = "319" . $yy . "\n"; -no warnings 'misc'; +no warnings 'y2k'; $x = "19$yy\n"; $x = "19" . $yy . "\n"; EXPECT diff --git a/t/pragma/warn/regcomp b/t/pragma/warn/regcomp index bb208db6bd..7d485f2efd 100644 --- a/t/pragma/warn/regcomp +++ b/t/pragma/warn/regcomp @@ -7,7 +7,7 @@ $a = "ABC123" ; $a =~ /(?=a)*/' /%.127s/: Unrecognized escape \\%c passed through" [S_regatom] - /\m/ + $x = '\m' ; /$x/ Character class syntax [. .] is reserved for future extensions [S_regpposixcc] @@ -25,33 +25,34 @@ __END__ # regcomp.c [S_regpiece] -use warnings 'unsafe' ; +use warnings 'regexp' ; my $a = "ABC123" ; $a =~ /(?=a)*/ ; -no warnings 'unsafe' ; +no warnings 'regexp' ; $a =~ /(?=a)*/ ; EXPECT (?=a)* matches null string many times at - line 4. ######## # regcomp.c [S_study_chunk] -use warnings 'unsafe' ; +use warnings 'regexp' ; $_ = "" ; /(?=a)?/; -no warnings 'unsafe' ; +no warnings 'regexp' ; /(?=a)?/; EXPECT Strange *+?{} on zero-length expression at - line 4. ######## # regcomp.c [S_regatom] -use warnings 'unsafe' ; -$a =~ /a\mb\b/ ; -no warnings 'unsafe' ; -$a =~ /a\mb\b/ ; +$x = '\m' ; +use warnings 'regexp' ; +$a =~ /a$x/ ; +no warnings 'regexp' ; +$a =~ /a$x/ ; EXPECT -Unrecognized escape \m passed through at - line 3. +/a\m/: Unrecognized escape \m passed through at - line 4. ######## # regcomp.c [S_regpposixcc S_checkposixcc] -use warnings 'unsafe' ; +use warnings 'regexp' ; $_ = "" ; /[:alpha:]/; /[.bar.]/; @@ -60,7 +61,7 @@ $_ = "" ; /[[.foo.]]/; /[[=bar=]]/; /[:zog:]/; -no warnings 'unsafe' ; +no warnings 'regexp' ; /[:alpha:]/; /[.foo.]/; /[=bar=]/; @@ -83,7 +84,7 @@ Character class [:zog:] unknown at - line 20. ######## # regcomp.c [S_regclass] $_ = ""; -use warnings 'unsafe' ; +use warnings 'regexp' ; /[a-b]/; /[a-\d]/; /[\d-b]/; @@ -93,7 +94,7 @@ use warnings 'unsafe' ; /[[:digit:]-b]/; /[[:alpha:]-[:digit:]]/; /[[:digit:]-[:alpha:]]/; -no warnings 'unsafe' ; +no warnings 'regexp' ; /[a-b]/; /[a-\d]/; /[\d-b]/; @@ -122,7 +123,7 @@ BEGIN { } use utf8; $_ = ""; -use warnings 'unsafe' ; +use warnings 'regexp' ; /[a-b]/; /[a-\d]/; /[\d-b]/; @@ -132,7 +133,7 @@ use warnings 'unsafe' ; /[[:digit:]-b]/; /[[:alpha:]-[:digit:]]/; /[[:digit:]-[:alpha:]]/; -no warnings 'unsafe' ; +no warnings 'regexp' ; /[a-b]/; /[a-\d]/; /[\d-b]/; @@ -153,9 +154,9 @@ EXPECT /[[:digit:]-[:alpha:]]/: false [] range "[:digit:]-" in regexp at - line 19. ######## # regcomp.c [S_regclass S_regclassutf8] -use warnings 'unsafe' ; +use warnings 'regexp' ; $a =~ /[a\zb]/ ; -no warnings 'unsafe' ; +no warnings 'regexp' ; $a =~ /[a\zb]/ ; EXPECT /[a\zb]/: Unrecognized escape \z in character class passed through at - line 3. diff --git a/t/pragma/warn/regexec b/t/pragma/warn/regexec index b9ba790832..73696dfb1d 100644 --- a/t/pragma/warn/regexec +++ b/t/pragma/warn/regexec @@ -16,7 +16,7 @@ __END__ # regexec.c print("SKIPPED\n# most systems run into stacksize limits\n"),exit; -use warnings 'unsafe' ; +use warnings 'regexp' ; $SIG{__WARN__} = sub{local ($m) = shift; $m =~ s/\(\d+\)/(*MASKED*)/; print STDERR $m}; @@ -42,7 +42,7 @@ Complex regular subexpression recursion limit (*MASKED*) exceeded at - line 9. ######## # regexec.c print("SKIPPED\n# most systems run into stacksize limits\n"),exit; -no warnings 'unsafe' ; +no warnings 'regexp' ; $SIG{__WARN__} = sub{local ($m) = shift; $m =~ s/\(\d+\)/(*MASKED*)/; print STDERR $m}; @@ -68,7 +68,7 @@ EXPECT ######## # regexec.c print("SKIPPED\n# most systems run into stacksize limits\n"),exit; -use warnings 'unsafe' ; +use warnings 'regexp' ; $SIG{__WARN__} = sub{local ($m) = shift; $m =~ s/\(\d+\)/(*MASKED*)/; print STDERR $m}; @@ -94,7 +94,7 @@ Complex regular subexpression recursion limit (*MASKED*) exceeded at - line 9. ######## # regexec.c print("SKIPPED\n# most systems run into stacksize limits\n"),exit; -no warnings 'unsafe' ; +no warnings 'regexp' ; $SIG{__WARN__} = sub{local ($m) = shift; $m =~ s/\(\d+\)/(*MASKED*)/; print STDERR $m}; diff --git a/t/pragma/warn/sv b/t/pragma/warn/sv index cdec48e2c2..9a2428e0cb 100644 --- a/t/pragma/warn/sv +++ b/t/pragma/warn/sv @@ -261,9 +261,9 @@ Invalid conversion in printf: end of string at - line 6. Invalid conversion in printf: "%\002" at - line 8. ######## # sv.c -use warnings 'unsafe' ; +use warnings 'misc' ; *a = undef ; -no warnings 'unsafe' ; +no warnings 'misc' ; *b = undef ; EXPECT Undefined value assigned to typeglob at - line 3. @@ -288,7 +288,7 @@ EXPECT \xff will produce malformed UTF-8 character; use \x{ff} for that at - line 12. ######## # sv.c -use warnings 'misc'; +use warnings 'y2k'; use Config; BEGIN { unless ($Config{ccflags} =~ /Y2KWARN/) { @@ -305,7 +305,7 @@ $x = printf " 19%02d\n", 78; $x = sprintf "19%02d\n", 78; $x = printf "319%02d\n", $yy; $x = sprintf "319%02d\n", $yy; -no warnings 'misc'; +no warnings 'y2k'; $x = printf "19%02d\n", $yy; $x = sprintf "19%02d\n", $yy; $x = printf "19%02d\n", 78; diff --git a/t/pragma/warn/toke b/t/pragma/warn/toke index 6ba9c56d3a..271ef6365c 100644 --- a/t/pragma/warn/toke +++ b/t/pragma/warn/toke @@ -300,33 +300,33 @@ EXPECT Unquoted string "abc" may clash with future reserved word at - line 3. ######## # toke.c -use warnings 'octal' ; +use warnings 'chmod' ; chmod 3; -no warnings 'octal' ; +no warnings 'chmod' ; chmod 3; EXPECT chmod() mode argument is missing initial 0 at - line 3. ######## # toke.c -use warnings 'syntax' ; +use warnings 'qw' ; @a = qw(a, b, c) ; -no warnings 'syntax' ; +no warnings 'qw' ; @a = qw(a, b, c) ; EXPECT Possible attempt to separate words with commas at - line 3. ######## # toke.c -use warnings 'syntax' ; +use warnings 'qw' ; @a = qw(a b #) ; -no warnings 'syntax' ; +no warnings 'qw' ; @a = qw(a b #) ; EXPECT Possible attempt to put comments in qw() list at - line 3. ######## # toke.c -use warnings 'octal' ; +use warnings 'umask' ; umask 3; -no warnings 'octal' ; +no warnings 'umask' ; umask 3; EXPECT umask: argument is missing initial 0 at - line 3. @@ -417,10 +417,10 @@ Misplaced _ in number at - line 4. Misplaced _ in number at - line 4. ######## # toke.c -use warnings 'unsafe' ; +use warnings 'bareword' ; #line 25 "bar" $a = FRED:: ; -no warnings 'unsafe' ; +no warnings 'bareword' ; #line 25 "bar" $a = FRED:: ; EXPECT @@ -512,9 +512,9 @@ Precedence problem: open FOO should be open(FOO) at - line 2. $^W = 0 ; open FOO || time; { - no warnings 'ambiguous' ; + no warnings 'precedence' ; open FOO || time; - use warnings 'ambiguous' ; + use warnings 'precedence' ; open FOO || time; } open FOO || time; @@ -542,9 +542,9 @@ Operator or semicolon missing before *foo at - line 10. Ambiguous use of * resolved as operator * at - line 10. ######## # toke.c -use warnings 'unsafe' ; +use warnings 'misc' ; my $a = "\m" ; -no warnings 'unsafe' ; +no warnings 'misc' ; $a = "\m" ; EXPECT Unrecognized escape \m passed through at - line 3. |