This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
toke.c: 'You need to quote %s' cleanup.
[perl5.git] / t / lib / warnings / toke
index b7653ce..2214005 100644 (file)
@@ -80,6 +80,9 @@ toke.c        AOK
     Unrecognized escape \\%c passed through
         $a = "\m" ;
 
+    Useless use of \\E.
+        $a = "abcd\E" ;
+
     %s number > %s non-portable
         my $a =  0b011111111111111111111111111111110 ;
         $a =  0b011111111111111111111111111111111 ;
@@ -234,6 +237,26 @@ EXPECT
 You need to quote "fred" at - line 3.
 ########
 # toke.c
+use utf8;
+use open qw( :utf8 :std );
+use warnings 'syntax' ;
+sub frèd {} ; $SIG{TERM} = frèd;
+no warnings 'syntax' ;
+$SIG{TERM} = frèd;
+EXPECT
+You need to quote "frèd" at - line 5.
+########
+# toke.c
+use utf8;
+use open qw( :utf8 :std );
+use warnings 'syntax' ;
+sub ふれど {} ; $SIG{TERM} = ふれど;
+no warnings 'syntax' ;
+$SIG{TERM} = ふれど;
+EXPECT
+You need to quote "ふれど" at - line 5.
+########
+# toke.c
 use warnings 'syntax' ;
 @a[3] = 2;
 @a{3} = 2;
@@ -275,13 +298,22 @@ Possible attempt to separate words with commas at - line 3.
 ########
 # toke.c
 use warnings 'qw' ;
-@a = qw(a b #) ;
+@a = qw(a b c # #) ;
 no warnings 'qw' ;
-@a = qw(a b #) ;
+@a = qw(a b c # #) ;
 EXPECT
 Possible attempt to put comments in qw() list at - line 3.
 ########
 # toke.c
+use warnings 'qw' ;
+@a = qw(a, b, c # #) ;
+no warnings 'qw' ;
+@a = qw(a, b, c # #) ;
+EXPECT
+Possible attempt to separate words with commas at - line 3.
+Possible attempt to put comments in qw() list at - line 3.
+########
+# toke.c
 use warnings 'syntax' ;
 print ("");
 print ("") and $x = 1;
@@ -598,6 +630,14 @@ Warning: Use of "rand" without parentheses is ambiguous at - line 3.
 Warning: Use of "rand" without parentheses is ambiguous at - line 8.
 Warning: Use of "rand" without parentheses is ambiguous at - line 10.
 ########
+# [perl #97110]
+sub myrand(;$) { }
+sub whatever($) { }
+my $a = myrand + 4 ;
+my $b = whatever + 4 ;
+EXPECT
+Warning: Use of "myrand" without parentheses is ambiguous at - line 4.
+########
 # toke.c
 use warnings "ambiguous";
 print for keys %+; # should not warn
@@ -627,6 +667,7 @@ Ambiguous use of -fred resolved as -&fred() at - line 11.
 ########
 # toke.c
 open FOO || time;
+open local *FOO; # should be ok
 EXPECT
 Precedence problem: open FOO should be open(FOO) at - line 2.
 ########
@@ -644,6 +685,7 @@ open FOO || time;
     open FOO || time;
 }
 open FOO || time;
+open Foo::BAR; # this should not warn
 EXPECT
 Precedence problem: open FOO should be open(FOO) at - line 3.
 Precedence problem: open FOO should be open(FOO) at - line 8.
@@ -676,6 +718,14 @@ EXPECT
 Unrecognized escape \m passed through at - line 3.
 ########
 # toke.c
+use warnings 'misc' ;
+my $a = "abcd\E" ;
+no warnings 'misc' ;
+$a = "abcd\E" ;
+EXPECT
+Useless use of \E at - line 3.
+########
+# toke.c
 use warnings 'portable' ;
 my $a =  0b011111111111111111111111111111110 ;
    $a =  0b011111111111111111111111111111111 ;