This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perlapi: Fix grammar
[perl5.git] / t / lib / warnings / regcomp
index 09caf03..44ef5c3 100644 (file)
-  XXX Note that t/re/reg_mesg.t might be a better place for these
-
-  regcomp.c    AOK
-
-  Quantifier unexpected on zero-length expression [S_study_chunk] 
-
-  Useless (%s%c) - %suse /%c modifier [S_reg] 
-  Useless (%sc) - %suse /gc modifier [S_reg] 
-
-
-
-  Strange *+?{} on zero-length expression      [S_study_chunk]
-       /(?=a)?/
-
-  %.*s matches null string many times          [S_regpiece]
-       $a = "ABC123" ; $a =~ /(?=a)*/'
-
-  /%.127s/: Unrecognized escape \\%c passed through    [S_regatom] 
-       $x = '\m' ; /$x/
-
-  POSIX syntax [%c %c] belongs inside character classes        [S_regclass] 
-
-
-  Character class [:%.*s:] unknown     [S_regpposixcc]
-
-  Character class syntax [%c %c] belongs inside character classes [S_regclass] 
-  
-  /%.127s/: false [] range \"%*.*s\" in regexp [S_regclass]
-
-  /%.127s/: false [] range \"%*.*s\" in regexp [S_regclassutf8]
-
-  /%.127s/: Unrecognized escape \\%c in character class passed through"        [S_regclass] 
-
-  /%.127s/: Unrecognized escape \\%c in character class passed through"        [S_regclassutf8] 
-
-  False [] range \"%*.*s\" [S_regclass]
+  regcomp.c    These tests have been moved to t/re/reg_mesg.t
+               except for those that explicitly test line numbers
+                and those that don't have a <-- HERE in them, and those that
+                die plus have warnings, or otherwise require special handling
 
 __END__
-# regcomp.c [S_regpiece]
-use warnings 'regexp' ;
-my $a = "ABC123" ; 
-$a =~ /(?=a)*/ ;
-no warnings 'regexp' ;
-$a =~ /(?=a)*/ ;
-EXPECT
-(?=a)* matches null string many times in regex; marked by <-- HERE in m/(?=a)* <-- HERE / at - line 4.
-########
-# regcomp.c [S_regatom]
-$x = '\m' ;
-use warnings 'regexp' ;
-$a =~ /a$x/ ;
-no warnings 'regexp' ;
-$a =~ /a$x/ ;
-EXPECT
-Unrecognized escape \m passed through in regex; marked by <-- HERE in m/a\m <-- HERE / at - line 4.
-########
-# regcomp.c [S_regatom]
-# The \q should warn, the \_ should NOT warn.
-use warnings 'regexp'; no warnings "deprecated";
-"foo" =~ /\q/;
-"foo" =~ /\q{/;
-"foo" =~ /\w{/;
-"foo" =~ /a\b{cde/;
-"foo" =~ /a\B{cde/;
-"bar" =~ /\_/;
-no warnings 'regexp';
-"foo" =~ /\q/;
-"foo" =~ /\q{/;
-"foo" =~ /\w{/;
-"foo" =~ /a\b{cde/;
-"foo" =~ /a\B{cde/;
-"bar" =~ /\_/;
-EXPECT
-Unrecognized escape \q passed through in regex; marked by <-- HERE in m/\q <-- HERE / at - line 4.
-Unrecognized escape \q passed through in regex; marked by <-- HERE in m/\q <-- HERE {/ at - line 5.
-Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/\q{ <-- HERE / at - line 5.
-Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/\w{ <-- HERE / at - line 6.
-Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/a\b{ <-- HERE cde/ at - line 7.
-Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/a\B{ <-- HERE cde/ at - line 8.
-########
-# regcomp.c [S_regpposixcc S_regclass]
-#
-use warnings 'regexp' ;
-$_ = "" ;
-/[:alpha:]/;
-/[:zog:]/;
-no warnings 'regexp' ;
-/[:alpha:]/;
-/[:zog:]/;
-EXPECT
-POSIX syntax [: :] belongs inside character classes in regex; marked by <-- HERE in m/[:alpha:] <-- HERE / at - line 5.
-POSIX syntax [: :] belongs inside character classes in regex; marked by <-- HERE in m/[:zog:] <-- HERE / at - line 6.
-########
-# regcomp.c [S_regclass]
-#
-use warnings 'regexp' ;
-$_ = "" ;
-/[.zog.]/;
-no warnings 'regexp' ;
-/[.zog.]/;
+use warnings 'regexp';
+$r=qr/(??{ q"\\b+" })/;
+"a" =~ /a$r/; # warning should come from this line
 EXPECT
-POSIX syntax [. .] belongs inside character classes in regex; marked by <-- HERE in m/[.zog.] <-- HERE / at - line 5.
+\b+ matches null string many times in regex; marked by <-- HERE in m/\b+ <-- HERE / at - line 3.
 ########
-# regcomp.c [S_regclass]
-$_ = "";
-use warnings 'regexp' ;
-/[a-b]/;
-/[a-\d]/;
-/[\d-b]/;
-/[\s-\d]/;
-/[\d-\s]/;
-/[a-[:digit:]]/;
-/[[:digit:]-b]/;
-/[[:alpha:]-[:digit:]]/;
-/[[:digit:]-[:alpha:]]/;
-no warnings 'regexp' ;
-/[a-b]/;
-/[a-\d]/;
-/[\d-b]/;
-/[\s-\d]/;
-/[\d-\s]/;
-/[a-[:digit:]]/;
-/[[:digit:]-b]/;
-/[[:alpha:]-[:digit:]]/;
-/[[:digit:]-[:alpha:]]/;
+# regcomp.c
+use warnings 'digit' ;
+my $a = qr/\o{1238456}\x{100}/;
+my $a = qr/[\o{6548321}]\x{100}/;
+no warnings 'digit' ;
+my $a = qr/\o{1238456}\x{100}/;
+my $a = qr/[\o{6548321}]\x{100}/;
 EXPECT
-False [] range "a-\d" in regex; marked by <-- HERE in m/[a-\d <-- HERE ]/ at - line 5.
-False [] range "\d-" in regex; marked by <-- HERE in m/[\d- <-- HERE b]/ at - line 6.
-False [] range "\s-" in regex; marked by <-- HERE in m/[\s- <-- HERE \d]/ at - line 7.
-False [] range "\d-" in regex; marked by <-- HERE in m/[\d- <-- HERE \s]/ at - line 8.
-False [] range "a-[:digit:]" in regex; marked by <-- HERE in m/[a-[:digit:] <-- HERE ]/ at - line 9.
-False [] range "[:digit:]-" in regex; marked by <-- HERE in m/[[:digit:]- <-- HERE b]/ at - line 10.
-False [] range "[:alpha:]-" in regex; marked by <-- HERE in m/[[:alpha:]- <-- HERE [:digit:]]/ at - line 11.
-False [] range "[:digit:]-" in regex; marked by <-- HERE in m/[[:digit:]- <-- HERE [:alpha:]]/ at - line 12.
+Non-octal character '8'.  Resolved as "\o{123}" at - line 3.
+Non-octal character '8'.  Resolved as "\o{654}" at - line 4.
 ########
-# regcomp.c [S_regclassutf8]
+# regcomp.c
 BEGIN {
-    if (ord("\t") == 5) {
-        print "SKIPPED\n# ebcdic regular expression ranges differ.";
+    if (ord('A') == 193) {
+        print "SKIPPED\n# Different results on EBCDIC";
         exit 0;
     }
 }
+use warnings;
+$a = qr/\c,/;
+$a = qr/[\c,]/;
+no warnings 'syntax', 'deprecated';
+$a = qr/\c,/;
+$a = qr/[\c,]/;
+EXPECT
+"\c," is more clearly written simply as "l". This will be a fatal error in Perl 5.28 at - line 9.
+"\c," is more clearly written simply as "l". This will be a fatal error in Perl 5.28 at - line 10.
+########
+# This is because currently a different error is output under
+# use re 'strict', so can't go in reg_mesg.t
+# NAME perl #126261, error message causes segfault
+# OPTION fatal
+ qr/abc[\x{df}[.00./i
+EXPECT
+Unmatched [ in regex; marked by <-- HERE in m/abc[ <-- HERE \x{df}[.00./ at - line 4.
+########
+# NAME perl #126261, with 'use utf8'
+# OPTION fatal
 use utf8;
-$_ = "";
-use warnings 'regexp' ;
-/[a-b]/;
-/[a-\d]/;
-/[\d-b]/;
-/[\s-\d]/;
-/[\d-\s]/;
-/[a-[:digit:]]/;
-/[[:digit:]-b]/;
-/[[:alpha:]-[:digit:]]/;
-/[[:digit:]-[:alpha:]]/;
-no warnings 'regexp' ;
-/[a-b]/;
-/[a-\d]/;
-/[\d-b]/;
-/[\s-\d]/;
-/[\d-\s]/;
-/[a-[:digit:]]/;
-/[[:digit:]-b]/;
-/[[:alpha:]-[:digit:]]/;
-/[[:digit:]-[:alpha:]]/;
-EXPECT
-False [] range "a-\d" in regex; marked by <-- HERE in m/[a-\d <-- HERE ]/ at - line 12.
-False [] range "\d-" in regex; marked by <-- HERE in m/[\d- <-- HERE b]/ at - line 13.
-False [] range "\s-" in regex; marked by <-- HERE in m/[\s- <-- HERE \d]/ at - line 14.
-False [] range "\d-" in regex; marked by <-- HERE in m/[\d- <-- HERE \s]/ at - line 15.
-False [] range "a-[:digit:]" in regex; marked by <-- HERE in m/[a-[:digit:] <-- HERE ]/ at - line 16.
-False [] range "[:digit:]-" in regex; marked by <-- HERE in m/[[:digit:]- <-- HERE b]/ at - line 17.
-False [] range "[:alpha:]-" in regex; marked by <-- HERE in m/[[:alpha:]- <-- HERE [:digit:]]/ at - line 18.
-False [] range "[:digit:]-" in regex; marked by <-- HERE in m/[[:digit:]- <-- HERE [:alpha:]]/ at - line 19.
-########
-# regcomp.c [S_regclass S_regclassutf8]
-use warnings 'regexp' ;
-$a =~ /[a\zb]/ ;
-no warnings 'regexp' ;
-$a =~ /[a\zb]/ ;
-EXPECT
-Unrecognized escape \z in character class passed through in regex; marked by <-- HERE in m/[a\z <-- HERE b]/ at - line 3.
-
-########
-# regcomp.c [S_reg]
-use warnings 'regexp' ;
-$a = qr/(?c)/;
-$a = qr/(?-c)/;
-$a = qr/(?g)/;
-$a = qr/(?-g)/;
-$a = qr/(?o)/;
-$a = qr/(?-o)/;
-$a = qr/(?g-o)/;
-$a = qr/(?g-c)/;
-$a = qr/(?o-cg)/;  # (?c) means (?g) error won't be thrown
-$a = qr/(?ogc)/;
-no warnings 'regexp' ;
-$a = qr/(?c)/;
-$a = qr/(?-c)/;
-$a = qr/(?g)/;
-$a = qr/(?-g)/;
-$a = qr/(?o)/;
-$a = qr/(?-o)/;
-$a = qr/(?g-o)/;
-$a = qr/(?g-c)/;
-$a = qr/(?o-cg)/;  # (?c) means (?g) error won't be thrown
-$a = qr/(?ogc)/;
-#EXPECT
+no warnings 'utf8';
+qr/abc[fi[.00./i;
 EXPECT
-Useless (?c) - use /gc modifier in regex; marked by <-- HERE in m/(?c <-- HERE )/ at - line 3.
-Useless (?-c) - don't use /gc modifier in regex; marked by <-- HERE in m/(?-c <-- HERE )/ at - line 4.
-Useless (?g) - use /g modifier in regex; marked by <-- HERE in m/(?g <-- HERE )/ at - line 5.
-Useless (?-g) - don't use /g modifier in regex; marked by <-- HERE in m/(?-g <-- HERE )/ at - line 6.
-Useless (?o) - use /o modifier in regex; marked by <-- HERE in m/(?o <-- HERE )/ at - line 7.
-Useless (?-o) - don't use /o modifier in regex; marked by <-- HERE in m/(?-o <-- HERE )/ at - line 8.
-Useless (?g) - use /g modifier in regex; marked by <-- HERE in m/(?g <-- HERE -o)/ at - line 9.
-Useless (?-o) - don't use /o modifier in regex; marked by <-- HERE in m/(?g-o <-- HERE )/ at - line 9.
-Useless (?g) - use /g modifier in regex; marked by <-- HERE in m/(?g <-- HERE -c)/ at - line 10.
-Useless (?-c) - don't use /gc modifier in regex; marked by <-- HERE in m/(?g-c <-- HERE )/ at - line 10.
-Useless (?o) - use /o modifier in regex; marked by <-- HERE in m/(?o <-- HERE -cg)/ at - line 11.
-Useless (?-c) - don't use /gc modifier in regex; marked by <-- HERE in m/(?o-c <-- HERE g)/ at - line 11.
-Useless (?o) - use /o modifier in regex; marked by <-- HERE in m/(?o <-- HERE gc)/ at - line 12.
-Useless (?g) - use /g modifier in regex; marked by <-- HERE in m/(?og <-- HERE c)/ at - line 12.
-Useless (?c) - use /gc modifier in regex; marked by <-- HERE in m/(?ogc <-- HERE )/ at - line 12.
+Unmatched [ in regex; marked by <-- HERE in m/abc[ <-- HERE fi[.00./ at - line 4.
 ########
-# regcomp.c [S_regatom]
-$a = qr/\o{/;
+# NAME perl qr/(?[[[:word]]])/ XXX Why is 'syntax' lc?
+# OPTION fatal
+qr/(?[[[:word]]])/;
 EXPECT
-Missing right brace on \o{ in regex; marked by <-- HERE in m/\o{ <-- HERE / at - line 2.
+Assuming NOT a POSIX class since there is no terminating ':' in regex; marked by <-- HERE in m/(?[[[:word <-- HERE ]]])/ at - line 2.
+syntax error in (?[...]) in regex m/(?[[[:word]]])/ at - line 2.
 ########
-# regcomp.c [S_regatom]
-$a = qr/\o/;
+# NAME qr/(?[ [[:digit: ])/
+# OPTION fatal
+qr/(?[[[:digit: ])/;
 EXPECT
-Missing braces on \o{} in regex; marked by <-- HERE in m/\o <-- HERE / at - line 2.
+Assuming NOT a POSIX class since no blanks are allowed in one in regex; marked by <-- HERE in m/(?[[[:digit: ] <-- HERE )/ at - line 2.
+syntax error in (?[...]) in regex m/(?[[[:digit: ])/ at - line 2.
 ########
-# regcomp.c [S_regatom]
-$a = qr/\o{}/;
+# NAME qr/(?[ [:digit: ])/
+# OPTION fatal
+qr/(?[[:digit: ])/
 EXPECT
-Number with no digits in regex; marked by <-- HERE in m/\o{} <-- HERE / at - line 2.
+Assuming NOT a POSIX class since no blanks are allowed in one in regex; marked by <-- HERE in m/(?[[:digit: ] <-- HERE )/ at - line 2.
+syntax error in (?[...]) in regex m/(?[[:digit: ])/ at - line 2.
 ########
-# regcomp.c [S_regclass]
-$a = qr/[\o{]/;
+# NAME [perl #126141]
+# OPTION fatal
+eval {/$_/}, print "$_ ==> ", $@ || "OK!\n" for "]]]]]]]]][\\", "]]]]][\\"
 EXPECT
-Missing right brace on \o{ in regex; marked by <-- HERE in m/[\o{ <-- HERE ]/ at - line 2.
+]]]]]]]]][\ ==> Unmatched [ in regex; marked by <-- HERE in m/]]]]]]]]][\ <-- HERE / at - line 2.
+]]]]][\ ==> Unmatched [ in regex; marked by <-- HERE in m/]]]]][\ <-- HERE / at - line 2.
 ########
-# regcomp.c [S_regclass]
-$a = qr/[\o]/;
-EXPECT
-Missing braces on \o{} in regex; marked by <-- HERE in m/[\o <-- HERE ]/ at - line 2.
-########
-# regcomp.c [S_regclass]
-$a = qr/[\o{}]/;
-EXPECT
-Number with no digits in regex; marked by <-- HERE in m/[\o{} <-- HERE ]/ at - line 2.
-########
-# regcomp.c [S_regclass]
-use warnings 'regexp' ;
-$a = qr/[\8\9]/;
-$a = qr/[\_\0]/; # Should have no warnings on this and the remainder of this test
-$a = qr/[\07]/;
-$a = qr/[\006]/;
-$a = qr/[\0005]/;
-no warnings 'regexp' ;
-$a = qr/[\8\9]/;
-EXPECT
-Unrecognized escape \8 in character class passed through in regex; marked by <-- HERE in m/[\8 <-- HERE \9]/ at - line 3.
-Unrecognized escape \9 in character class passed through in regex; marked by <-- HERE in m/[\8\9 <-- HERE ]/ at - line 3.
-########
-# regcomp.c [Perl_re_compile]
-$a = qr/(?^-i:foo)/;
-EXPECT
-Sequence (?^-...) not recognized in regex; marked by <-- HERE in m/(?^- <-- HERE i:foo)/ at - line 2.
-########
-# regcomp.c [S_regatom]
-use warnings 'regexp' ;
-$a = qr/\87/;
-$a = qr/a\87/;
-$a = qr/a\97/;
-no warnings 'regexp' ;
-$a = qr/\87/;
-$a = qr/a\87/;
-$a = qr/a\97/;
-EXPECT
-Unrecognized escape \8 passed through in regex; marked by <-- HERE in m/\8 <-- HERE 7/ at - line 3.
-Unrecognized escape \8 passed through in regex; marked by <-- HERE in m/a\8 <-- HERE 7/ at - line 4.
-Unrecognized escape \9 passed through in regex; marked by <-- HERE in m/a\9 <-- HERE 7/ at - line 5.
+# NAME [perl #123417]
+use warnings 'regexp';
+qr/[\N{}]/;
+qr/\N{}/;
+no warnings 'regexp';
+qr/[\N{}]/;
+qr/\N{}/;
+no warnings 'deprecated';
+qr/[\N{}]/;
+qr/\N{}/;
+EXPECT
+Unknown charname '' is deprecated. Its use will be fatal in Perl 5.28 at - line 2.
+Ignoring zero length \N{} in character class in regex; marked by <-- HERE in m/[\N{} <-- HERE ]/ at - line 2.
+Unknown charname '' is deprecated. Its use will be fatal in Perl 5.28 at - line 3.
+Unknown charname '' is deprecated. Its use will be fatal in Perl 5.28 at - line 5.
+Unknown charname '' is deprecated. Its use will be fatal in Perl 5.28 at - line 6.
+########
+# NAME [perl #123417]
+# OPTION fatal
+use warnings 'regexp';
+no warnings 'experimental::re_strict';
+use re 'strict';
+qr/[\N{}]/;
+EXPECT
+Unknown charname '' is deprecated. Its use will be fatal in Perl 5.28 at - line 5.
+Zero length \N{} in regex; marked by <-- HERE in m/[\N{} <-- HERE ]/ at - line 5.
+########
+# NAME [perl #123417]
+# OPTION fatal
+use warnings 'regexp';
+no warnings 'experimental::re_strict';
+use re 'strict';
+qr/\N{}/;
+EXPECT
+Unknown charname '' is deprecated. Its use will be fatal in Perl 5.28 at - line 5.
+Zero length \N{} in regex; marked by <-- HERE in m/\N{} <-- HERE / at - line 5.