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