(?p{}) has been deprecated for a long time.
[p5sagit/p5-mst-13.2.git] / t / lib / warnings / regcomp
CommitLineData
599cee73 1 regcomp.c AOK
2
f9373011 3 Quantifier unexpected on zero-length expression [S_study_chunk]
4
f9373011 5 Useless (%s%c) - %suse /%c modifier [S_reg]
6 Useless (%sc) - %suse /gc modifier [S_reg]
7
8
9
767a6a26 10 Strange *+?{} on zero-length expression [S_study_chunk]
11 /(?=a)?/
599cee73 12
767a6a26 13 %.*s matches null string many times [S_regpiece]
599cee73 14 $a = "ABC123" ; $a =~ /(?=a)*/'
15
ac561586 16 /%.127s/: Unrecognized escape \\%c passed through [S_regatom]
e476b1b5 17 $x = '\m' ; /$x/
599cee73 18
cd84f5b2 19 POSIX syntax [%c %c] belongs inside character classes [S_checkposixcc]
f9373011 20
21
ac561586 22 Character class [:%.*s:] unknown [S_regpposixcc]
23
767a6a26 24 Character class syntax [%c %c] belongs inside character classes [S_checkposixcc]
25
73b437c8 26 /%.127s/: false [] range \"%*.*s\" in regexp [S_regclass]
599cee73 27
73b437c8 28 /%.127s/: false [] range \"%*.*s\" in regexp [S_regclassutf8]
599cee73 29
1028017a 30 /%.127s/: Unrecognized escape \\%c in character class passed through" [S_regclass]
31
32 /%.127s/: Unrecognized escape \\%c in character class passed through" [S_regclassutf8]
33
f9373011 34 False [] range \"%*.*s\" [S_regclass]
35
599cee73 36__END__
767a6a26 37# regcomp.c [S_regpiece]
e476b1b5 38use warnings 'regexp' ;
599cee73 39my $a = "ABC123" ;
40$a =~ /(?=a)*/ ;
e476b1b5 41no warnings 'regexp' ;
0453d815 42$a =~ /(?=a)*/ ;
599cee73 43EXPECT
7253e4e3 44(?=a)* matches null string many times in regex; marked by <-- HERE in m/(?=a)* <-- HERE / at - line 4.
599cee73 45########
767a6a26 46# regcomp.c [S_regatom]
e476b1b5 47$x = '\m' ;
48use warnings 'regexp' ;
49$a =~ /a$x/ ;
50no warnings 'regexp' ;
51$a =~ /a$x/ ;
767a6a26 52EXPECT
7253e4e3 53Unrecognized escape \m passed through in regex; marked by <-- HERE in m/a\m <-- HERE / at - line 4.
767a6a26 54########
cc74c5bd 55# regcomp.c [S_regatom]
56# The \q should warn, the \_ should NOT warn.
57use warnings 'regexp';
58"foo" =~ /\q/;
59"bar" =~ /\_/;
60no warnings 'regexp';
61"foo" =~ /\q/;
62"bar" =~ /\_/;
63EXPECT
64Unrecognized escape \q passed through in regex; marked by <-- HERE in m/\q <-- HERE / at - line 4.
65########
767a6a26 66# regcomp.c [S_regpposixcc S_checkposixcc]
7f01dc7a 67#
e476b1b5 68use warnings 'regexp' ;
599cee73 69$_ = "" ;
e8c223df 70/[:alpha:]/;
e8c223df 71/[:zog:]/;
e476b1b5 72no warnings 'regexp' ;
e8c223df 73/[:alpha:]/;
ac561586 74/[:zog:]/;
599cee73 75EXPECT
7253e4e3 76POSIX syntax [: :] belongs inside character classes in regex; marked by <-- HERE in m/[:alpha:] <-- HERE / at - line 5.
77POSIX syntax [: :] belongs inside character classes in regex; marked by <-- HERE in m/[:zog:] <-- HERE / at - line 6.
3802429d 78########
79# regcomp.c [S_checkposixcc]
7f01dc7a 80#
3802429d 81use warnings 'regexp' ;
82$_ = "" ;
83/[.zog.]/;
84no warnings 'regexp' ;
85/[.zog.]/;
86EXPECT
7253e4e3 87POSIX syntax [. .] belongs inside character classes in regex; marked by <-- HERE in m/[.zog.] <-- HERE / at - line 5.
d0808320 88POSIX syntax [. .] is reserved for future extensions in regex; marked by <-- HERE in m/[.zog.] <-- HERE / at - line 5.
3802429d 89########
73b437c8 90# regcomp.c [S_regclass]
91$_ = "";
e476b1b5 92use warnings 'regexp' ;
73b437c8 93/[a-b]/;
94/[a-\d]/;
95/[\d-b]/;
96/[\s-\d]/;
97/[\d-\s]/;
98/[a-[:digit:]]/;
99/[[:digit:]-b]/;
100/[[:alpha:]-[:digit:]]/;
101/[[:digit:]-[:alpha:]]/;
e476b1b5 102no warnings 'regexp' ;
73b437c8 103/[a-b]/;
104/[a-\d]/;
105/[\d-b]/;
106/[\s-\d]/;
107/[\d-\s]/;
108/[a-[:digit:]]/;
109/[[:digit:]-b]/;
110/[[:alpha:]-[:digit:]]/;
111/[[:digit:]-[:alpha:]]/;
112EXPECT
7253e4e3 113False [] range "a-\d" in regex; marked by <-- HERE in m/[a-\d <-- HERE ]/ at - line 5.
114False [] range "\d-" in regex; marked by <-- HERE in m/[\d- <-- HERE b]/ at - line 6.
115False [] range "\s-" in regex; marked by <-- HERE in m/[\s- <-- HERE \d]/ at - line 7.
116False [] range "\d-" in regex; marked by <-- HERE in m/[\d- <-- HERE \s]/ at - line 8.
117False [] range "a-[:digit:]" in regex; marked by <-- HERE in m/[a-[:digit:] <-- HERE ]/ at - line 9.
118False [] range "[:digit:]-" in regex; marked by <-- HERE in m/[[:digit:]- <-- HERE b]/ at - line 10.
119False [] range "[:alpha:]-" in regex; marked by <-- HERE in m/[[:alpha:]- <-- HERE [:digit:]]/ at - line 11.
120False [] range "[:digit:]-" in regex; marked by <-- HERE in m/[[:digit:]- <-- HERE [:alpha:]]/ at - line 12.
73b437c8 121########
122# regcomp.c [S_regclassutf8]
59af8754 123BEGIN {
124 if (ord("\t") == 5) {
125 print "SKIPPED\n# ebcdic regular expression ranges differ.";
126 exit 0;
127 }
128}
73b437c8 129use utf8;
130$_ = "";
e476b1b5 131use warnings 'regexp' ;
73b437c8 132/[a-b]/;
133/[a-\d]/;
134/[\d-b]/;
135/[\s-\d]/;
136/[\d-\s]/;
137/[a-[:digit:]]/;
138/[[:digit:]-b]/;
139/[[:alpha:]-[:digit:]]/;
140/[[:digit:]-[:alpha:]]/;
e476b1b5 141no warnings 'regexp' ;
73b437c8 142/[a-b]/;
143/[a-\d]/;
144/[\d-b]/;
145/[\s-\d]/;
146/[\d-\s]/;
147/[a-[:digit:]]/;
148/[[:digit:]-b]/;
149/[[:alpha:]-[:digit:]]/;
150/[[:digit:]-[:alpha:]]/;
151EXPECT
7253e4e3 152False [] range "a-\d" in regex; marked by <-- HERE in m/[a-\d <-- HERE ]/ at - line 12.
153False [] range "\d-" in regex; marked by <-- HERE in m/[\d- <-- HERE b]/ at - line 13.
154False [] range "\s-" in regex; marked by <-- HERE in m/[\s- <-- HERE \d]/ at - line 14.
155False [] range "\d-" in regex; marked by <-- HERE in m/[\d- <-- HERE \s]/ at - line 15.
156False [] range "a-[:digit:]" in regex; marked by <-- HERE in m/[a-[:digit:] <-- HERE ]/ at - line 16.
157False [] range "[:digit:]-" in regex; marked by <-- HERE in m/[[:digit:]- <-- HERE b]/ at - line 17.
158False [] range "[:alpha:]-" in regex; marked by <-- HERE in m/[[:alpha:]- <-- HERE [:digit:]]/ at - line 18.
159False [] range "[:digit:]-" in regex; marked by <-- HERE in m/[[:digit:]- <-- HERE [:alpha:]]/ at - line 19.
1028017a 160########
161# regcomp.c [S_regclass S_regclassutf8]
e476b1b5 162use warnings 'regexp' ;
1028017a 163$a =~ /[a\zb]/ ;
e476b1b5 164no warnings 'regexp' ;
1028017a 165$a =~ /[a\zb]/ ;
166EXPECT
7253e4e3 167Unrecognized escape \z in character class passed through in regex; marked by <-- HERE in m/[a\z <-- HERE b]/ at - line 3.
b45f050a 168
f9373011 169########
f9373011 170# regcomp.c [S_reg]
171use warnings 'regexp' ;
172$a = qr/(?c)/;
173$a = qr/(?-c)/;
174$a = qr/(?g)/;
175$a = qr/(?-g)/;
176$a = qr/(?o)/;
177$a = qr/(?-o)/;
178$a = qr/(?g-o)/;
179$a = qr/(?g-c)/;
180$a = qr/(?o-cg)/; # (?c) means (?g) error won't be thrown
181$a = qr/(?ogc)/;
182no warnings 'regexp' ;
183$a = qr/(?c)/;
184$a = qr/(?-c)/;
185$a = qr/(?g)/;
186$a = qr/(?-g)/;
187$a = qr/(?o)/;
188$a = qr/(?-o)/;
189$a = qr/(?g-o)/;
190$a = qr/(?g-c)/;
191$a = qr/(?o-cg)/; # (?c) means (?g) error won't be thrown
192$a = qr/(?ogc)/;
193#EXPECT
194EXPECT
195Useless (?c) - use /gc modifier in regex; marked by <-- HERE in m/(?c <-- HERE )/ at - line 3.
196Useless (?-c) - don't use /gc modifier in regex; marked by <-- HERE in m/(?-c <-- HERE )/ at - line 4.
197Useless (?g) - use /g modifier in regex; marked by <-- HERE in m/(?g <-- HERE )/ at - line 5.
198Useless (?-g) - don't use /g modifier in regex; marked by <-- HERE in m/(?-g <-- HERE )/ at - line 6.
199Useless (?o) - use /o modifier in regex; marked by <-- HERE in m/(?o <-- HERE )/ at - line 7.
200Useless (?-o) - don't use /o modifier in regex; marked by <-- HERE in m/(?-o <-- HERE )/ at - line 8.
201Useless (?g) - use /g modifier in regex; marked by <-- HERE in m/(?g <-- HERE -o)/ at - line 9.
202Useless (?-o) - don't use /o modifier in regex; marked by <-- HERE in m/(?g-o <-- HERE )/ at - line 9.
203Useless (?g) - use /g modifier in regex; marked by <-- HERE in m/(?g <-- HERE -c)/ at - line 10.
204Useless (?-c) - don't use /gc modifier in regex; marked by <-- HERE in m/(?g-c <-- HERE )/ at - line 10.
205Useless (?o) - use /o modifier in regex; marked by <-- HERE in m/(?o <-- HERE -cg)/ at - line 11.
206Useless (?-c) - don't use /gc modifier in regex; marked by <-- HERE in m/(?o-c <-- HERE g)/ at - line 11.
207Useless (?o) - use /o modifier in regex; marked by <-- HERE in m/(?o <-- HERE gc)/ at - line 12.
208Useless (?g) - use /g modifier in regex; marked by <-- HERE in m/(?og <-- HERE c)/ at - line 12.
209Useless (?c) - use /gc modifier in regex; marked by <-- HERE in m/(?ogc <-- HERE )/ at - line 12.