This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix typos (spelling errors) in README*.
[perl5.git] / t / re / pat.t
CommitLineData
8d063cd8 1#!./perl
8d37f932
DD
2#
3# This is a home for regular expression tests that don't fit into
67a2b8c6 4# the format supported by re/regexp.t. If you want to add a test
ff3f963a
KW
5# that does fit that format, add it to re/re_tests, not here. Tests for \N
6# should be added here because they are treated as single quoted strings
7# there, which means they avoid the lexer which otherwise would look at them.
8d063cd8 8
84281c31
A
9use strict;
10use warnings;
11use 5.010;
12
13
14sub run_tests;
15
9133bbab 16$| = 1;
3568d838 17
8d37f932 18
e4d48cc9
GS
19BEGIN {
20 chdir 't' if -d 't';
9d45b377
YO
21 @INC = ('../lib','.');
22 do "re/ReTest.pl" or die $@;
e4d48cc9 23}
84281c31 24
84281c31 25
54a4274e 26plan tests => 423; # Update this when adding/deleting tests.
b7a35066 27
9d45b377 28run_tests() unless caller;
b7a35066 29
84281c31
A
30#
31# Tests start here.
32#
33sub run_tests {
0ef3e39e 34
84281c31 35 {
b485d051 36
84281c31 37 my $x = "abc\ndef\n";
fd291da9 38
84281c31
A
39 ok $x =~ /^abc/, qq ["$x" =~ /^abc/];
40 ok $x !~ /^def/, qq ["$x" !~ /^def/];
fd291da9 41
84281c31
A
42 # used to be a test for $*
43 ok $x =~ /^def/m, qq ["$x" =~ /^def/m];
fd291da9 44
84281c31
A
45 nok $x =~ /^xxx/, qq ["$x" =~ /^xxx/];
46 nok $x !~ /^abc/, qq ["$x" !~ /^abc/];
fd291da9 47
84281c31
A
48 ok $x =~ /def/, qq ["$x" =~ /def/];
49 nok $x !~ /def/, qq ["$x" !~ /def/];
4765795a 50
84281c31
A
51 ok $x !~ /.def/, qq ["$x" !~ /.def/];
52 nok $x =~ /.def/, qq ["$x" =~ /.def/];
4765795a 53
84281c31
A
54 ok $x =~ /\ndef/, qq ["$x" =~ /\ndef/];
55 nok $x !~ /\ndef/, qq ["$x" !~ /\ndef/];
56 }
4765795a 57
84281c31
A
58 {
59 $_ = '123';
60 ok /^([0-9][0-9]*)/, qq [\$_ = '$_'; /^([0-9][0-9]*)/];
61 }
f9969324 62
84281c31
A
63 {
64 $_ = 'aaabbbccc';
65 ok /(a*b*)(c*)/ && $1 eq 'aaabbb' && $2 eq 'ccc',
66 qq [\$_ = '$_'; /(a*b*)(c*)/];
67 ok /(a+b+c+)/ && $1 eq 'aaabbbccc', qq [\$_ = '$_'; /(a+b+c+)/];
68 nok /a+b?c+/, qq [\$_ = '$_'; /a+b?c+/];
69
70 $_ = 'aaabccc';
71 ok /a+b?c+/, qq [\$_ = '$_'; /a+b?c+/];
72 ok /a*b?c*/, qq [\$_ = '$_'; /a*b?c*/];
73
74 $_ = 'aaaccc';
75 ok /a*b?c*/, qq [\$_ = '$_'; /a*b?c*/];
76 nok /a*b+c*/, qq [\$_ = '$_'; /a*b+c*/];
77
78 $_ = 'abcdef';
79 ok /bcd|xyz/, qq [\$_ = '$_'; /bcd|xyz/];
80 ok /xyz|bcd/, qq [\$_ = '$_'; /xyz|bcd/];
81 ok m|bc/*d|, qq [\$_ = '$_'; m|bc/*d|];
82 ok /^$_$/, qq [\$_ = '$_'; /^\$_\$/];
4765795a 83 }
4765795a 84
84281c31
A
85 {
86 # used to be a test for $*
87 ok "ab\ncd\n" =~ /^cd/m, qq ["ab\ncd\n" =~ /^cd/m];
88 }
4765795a 89
84281c31
A
90 {
91 our %XXX = map {($_ => $_)} 123, 234, 345;
92
93 our @XXX = ('ok 1','not ok 1', 'ok 2','not ok 2','not ok 3');
94 while ($_ = shift(@XXX)) {
95 my $f = index ($_, 'not') >= 0 ? \&nok : \&ok;
725a61d7 96 my $r = m?(.*)?;
84281c31
A
97 &$f ($r, "?(.*)?");
98 /not/ && reset;
99 if (/not ok 2/) {
100 if ($^O eq 'VMS') {
101 $_ = shift(@XXX);
102 }
103 else {
104 reset 'X';
105 }
106 }
107 }
4765795a 108
84281c31
A
109 SKIP: {
110 if ($^O eq 'VMS') {
111 skip "Reset 'X'", 1;
112 }
113 ok !keys %XXX, "%XXX is empty";
114 }
4765795a 115
84281c31 116 }
4765795a 117
84281c31
A
118 {
119 local $Message = "Test empty pattern";
120 my $xyz = 'xyz';
121 my $cde = 'cde';
122
123 $cde =~ /[^ab]*/;
124 $xyz =~ //;
125 iseq $&, $xyz;
126
127 my $foo = '[^ab]*';
128 $cde =~ /$foo/;
129 $xyz =~ //;
130 iseq $&, $xyz;
131
132 $cde =~ /$foo/;
133 my $null;
134 no warnings 'uninitialized';
135 $xyz =~ /$null/;
136 iseq $&, $xyz;
137
138 $null = "";
139 $xyz =~ /$null/;
140 iseq $&, $xyz;
141 }
4765795a 142
84281c31
A
143 {
144 local $Message = q !Check $`, $&, $'!;
145 $_ = 'abcdefghi';
0f289c68 146 /def/; # optimized up to cmd
84281c31 147 iseq "$`:$&:$'", 'abc:def:ghi';
4765795a 148
84281c31 149 no warnings 'void';
0f289c68 150 /cde/ + 0; # optimized only to spat
84281c31 151 iseq "$`:$&:$'", 'ab:cde:fghi';
4765795a 152
0f289c68 153 /[d][e][f]/; # not optimized
84281c31
A
154 iseq "$`:$&:$'", 'abc:def:ghi';
155 }
4765795a 156
84281c31
A
157 {
158 $_ = 'now is the {time for all} good men to come to.';
159 / {([^}]*)}/;
160 iseq $1, 'time for all', "Match braces";
161 }
4765795a 162
84281c31
A
163 {
164 local $Message = "{N,M} quantifier";
165 $_ = 'xxx {3,4} yyy zzz';
166 ok /( {3,4})/;
167 iseq $1, ' ';
168 ok !/( {4,})/;
169 ok /( {2,3}.)/;
170 iseq $1, ' y';
171 ok /(y{2,3}.)/;
172 iseq $1, 'yyy ';
173 ok !/x {3,4}/;
174 ok !/^xxx {3,4}/;
175 }
4765795a 176
84281c31
A
177 {
178 local $Message = "Test /g";
179 local $" = ":";
180 $_ = "now is the time for all good men to come to.";
181 my @words = /(\w+)/g;
182 my $exp = "now:is:the:time:for:all:good:men:to:come:to";
4765795a 183
84281c31 184 iseq "@words", $exp;
4765795a 185
84281c31
A
186 @words = ();
187 while (/\w+/g) {
188 push (@words, $&);
189 }
190 iseq "@words", $exp;
4765795a 191
84281c31
A
192 @words = ();
193 pos = 0;
194 while (/to/g) {
195 push(@words, $&);
196 }
197 iseq "@words", "to:to";
4765795a 198
84281c31
A
199 pos $_ = 0;
200 @words = /to/g;
201 iseq "@words", "to:to";
202 }
4765795a 203
84281c31
A
204 {
205 $_ = "abcdefghi";
206
207 my $pat1 = 'def';
208 my $pat2 = '^def';
209 my $pat3 = '.def.';
210 my $pat4 = 'abc';
211 my $pat5 = '^abc';
212 my $pat6 = 'abc$';
213 my $pat7 = 'ghi';
214 my $pat8 = '\w*ghi';
215 my $pat9 = 'ghi$';
216
217 my $t1 = my $t2 = my $t3 = my $t4 = my $t5 =
218 my $t6 = my $t7 = my $t8 = my $t9 = 0;
219
220 for my $iter (1 .. 5) {
221 $t1++ if /$pat1/o;
222 $t2++ if /$pat2/o;
223 $t3++ if /$pat3/o;
224 $t4++ if /$pat4/o;
225 $t5++ if /$pat5/o;
226 $t6++ if /$pat6/o;
227 $t7++ if /$pat7/o;
228 $t8++ if /$pat8/o;
229 $t9++ if /$pat9/o;
230 }
231 my $x = "$t1$t2$t3$t4$t5$t6$t7$t8$t9";
232 iseq $x, '505550555', "Test /o";
233 }
4765795a 234
4765795a 235
84281c31
A
236 SKIP: {
237 my $xyz = 'xyz';
238 ok "abc" =~ /^abc$|$xyz/, "| after \$";
4765795a 239
84281c31
A
240 # perl 4.009 says "unmatched ()"
241 local $Message = '$ inside ()';
4765795a 242
84281c31
A
243 my $result;
244 eval '"abc" =~ /a(bc$)|$xyz/; $result = "$&:$1"';
245 iseq $@, "" or skip "eval failed", 1;
246 iseq $result, "abc:bc";
247 }
4765795a 248
4765795a 249
84281c31
A
250 {
251 local $Message = "Scalar /g";
252 $_ = "abcfooabcbar";
253
254 ok /abc/g && $` eq "";
255 ok /abc/g && $` eq "abcfoo";
256 ok !/abc/g;
257
258 local $Message = "Scalar /gi";
259 pos = 0;
260 ok /ABC/gi && $` eq "";
261 ok /ABC/gi && $` eq "abcfoo";
262 ok !/ABC/gi;
263
264 local $Message = "Scalar /g";
265 pos = 0;
266 ok /abc/g && $' eq "fooabcbar";
267 ok /abc/g && $' eq "bar";
268
269 $_ .= '';
270 my @x = /abc/g;
271 iseq @x, 2, "/g reset after assignment";
4765795a 272 }
4765795a 273
84281c31
A
274 {
275 local $Message = '/g, \G and pos';
276 $_ = "abdc";
277 pos $_ = 2;
278 /\Gc/gc;
279 iseq pos $_, 2;
280 /\Gc/g;
281 ok !defined pos $_;
282 }
4765795a 283
84281c31
A
284 {
285 local $Message = '(?{ })';
286 our $out = 1;
287 'abc' =~ m'a(?{ $out = 2 })b';
288 iseq $out, 2;
289
290 $out = 1;
291 'abc' =~ m'a(?{ $out = 3 })c';
292 iseq $out, 1;
293 }
4765795a 294
4765795a 295
84281c31
A
296 {
297 $_ = 'foobar1 bar2 foobar3 barfoobar5 foobar6';
298 my @out = /(?<!foo)bar./g;
299 iseq "@out", 'bar2 barf', "Negative lookbehind";
300 }
4765795a 301
84281c31
A
302 {
303 local $Message = "REG_INFTY tests";
304 # Tests which depend on REG_INFTY
305 $::reg_infty = $Config {reg_infty} // 32767;
306 $::reg_infty_m = $::reg_infty - 1;
307 $::reg_infty_p = $::reg_infty + 1;
308 $::reg_infty_m = $::reg_infty_m; # Surpress warning.
309
310 # As well as failing if the pattern matches do unexpected things, the
311 # next three tests will fail if you should have picked up a lower-than-
312 # default value for $reg_infty from Config.pm, but have not.
313
314 eval_ok q (('aaa' =~ /(a{1,$::reg_infty_m})/)[0] eq 'aaa');
315 eval_ok q (('a' x $::reg_infty_m) =~ /a{$::reg_infty_m}/);
316 eval_ok q (('a' x ($::reg_infty_m - 1)) !~ /a{$::reg_infty_m}/);
317 eval "'aaa' =~ /a{1,$::reg_infty}/";
318 ok $@ =~ /^\QQuantifier in {,} bigger than/;
319 eval "'aaa' =~ /a{1,$::reg_infty_p}/";
320 ok $@ =~ /^\QQuantifier in {,} bigger than/;
4765795a 321 }
8269fa76 322
84281c31
A
323 {
324 # Poke a couple more parse failures
325 my $context = 'x' x 256;
326 eval qq("${context}y" =~ /(?<=$context)y/);
327 ok $@ =~ /^\QLookbehind longer than 255 not/, "Lookbehind limit";
328 }
8269fa76 329
84281c31
A
330 {
331 # Long Monsters
332 local $Message = "Long monster";
333 for my $l (125, 140, 250, 270, 300000, 30) { # Ordered to free memory
334 my $a = 'a' x $l;
335 local $Error = "length = $l";
336 ok "ba$a=" =~ /a$a=/;
337 nok "b$a=" =~ /a$a=/;
338 ok "b$a=" =~ /ba+=/;
339
84281c31
A
340 ok "ba$a=" =~ /b(?:a|b)+=/;
341 }
342 }
8269fa76 343
b8ef571c 344
84281c31
A
345 {
346 # 20000 nodes, each taking 3 words per string, and 1 per branch
347 my $long_constant_len = join '|', 12120 .. 32645;
348 my $long_var_len = join '|', 8120 .. 28645;
349 my %ans = ( 'ax13876y25677lbc' => 1,
350 'ax13876y25677mcb' => 0, # not b.
351 'ax13876y35677nbc' => 0, # Num too big
352 'ax13876y25677y21378obc' => 1,
0f289c68 353 'ax13876y25677y21378zbc' => 0, # Not followed by [k-o]
84281c31
A
354 'ax13876y25677y21378y21378kbc' => 1,
355 'ax13876y25677y21378y21378kcb' => 0, # Not b.
356 'ax13876y25677y21378y21378y21378kbc' => 0, # 5 runs
357 );
358
359 local $Message = "20000 nodes";
360 for (keys %ans) {
361 local $Error = "const-len '$_'";
362 ok !($ans{$_} xor /a(?=([yx]($long_constant_len)){2,4}[k-o]).*b./o);
363
364 local $Error = "var-len '$_'";
365 ok !($ans{$_} xor /a(?=([yx]($long_var_len)){2,4}[k-o]).*b./o);
366 }
b8ef571c 367 }
209a9bc1 368
84281c31
A
369 {
370 local $Message = "Complicated backtracking";
371 $_ = " a (bla()) and x(y b((l)u((e))) and b(l(e)e)e";
372 my $expect = "(bla()) ((l)u((e))) (l(e)e)";
373
374 use vars '$c';
375 sub matchit {
376 m/
377 (
378 \(
0f289c68 379 (?{ $c = 1 }) # Initialize
84281c31
A
380 (?:
381 (?(?{ $c == 0 }) # PREVIOUS iteration was OK, stop the loop
382 (?!
0f289c68
YO
383 ) # Fail: will unwind one iteration back
384 )
84281c31 385 (?:
0f289c68 386 [^()]+ # Match a big chunk
84281c31
A
387 (?=
388 [()]
0f289c68 389 ) # Do not try to match subchunks
84281c31
A
390 |
391 \(
392 (?{ ++$c })
393 |
394 \)
395 (?{ --$c })
396 )
0f289c68 397 )+ # This may not match with different subblocks
84281c31
A
398 )
399 (?(?{ $c != 0 })
400 (?!
0f289c68
YO
401 ) # Fail
402 ) # Otherwise the chunk 1 may succeed with $c>0
84281c31
A
403 /xg;
404 }
3568d838 405
84281c31
A
406 my @ans = ();
407 my $res;
408 push @ans, $res while $res = matchit;
409 iseq "@ans", "1 1 1";
3568d838 410
84281c31
A
411 @ans = matchit;
412 iseq "@ans", $expect;
3568d838 413
84281c31
A
414 local $Message = "Recursion with (??{ })";
415 our $matched;
416 $matched = qr/\((?:(?>[^()]+)|(??{$matched}))*\)/;
3568d838 417
84281c31
A
418 @ans = my @ans1 = ();
419 push (@ans, $res), push (@ans1, $&) while $res = m/$matched/g;
3568d838 420
84281c31
A
421 iseq "@ans", "1 1 1";
422 iseq "@ans1", $expect;
3568d838 423
84281c31
A
424 @ans = m/$matched/g;
425 iseq "@ans", $expect;
3568d838 426
84281c31 427 }
3568d838 428
84281c31
A
429 {
430 ok "abc" =~ /^(??{"a"})b/, '"abc" =~ /^(??{"a"})b/';
431 }
3568d838 432
84281c31 433 {
0f289c68 434 my @ans = ('a/b' =~ m%(.*/)?(.*)%); # Stack may be bad
84281c31
A
435 iseq "@ans", 'a/ b', "Stack may be bad";
436 }
3568d838 437
84281c31
A
438 {
439 local $Message = "Eval-group not allowed at runtime";
440 my $code = '{$blah = 45}';
441 our $blah = 12;
442 eval { /(?$code)/ };
443 ok $@ && $@ =~ /not allowed at runtime/ && $blah == 12;
444
445 for $code ('{$blah = 45}','=xx') {
446 $blah = 12;
447 my $res = eval { "xx" =~ /(?$code)/o };
448 no warnings 'uninitialized';
449 local $Error = "'$@', '$res', '$blah'";
450 if ($code eq '=xx') {
451 ok !$@ && $res;
452 }
453 else {
454 ok $@ && $@ =~ /not allowed at runtime/ && $blah == 12;
455 }
456 }
3568d838 457
84281c31
A
458 $code = '{$blah = 45}';
459 $blah = 12;
460 eval "/(?$code)/";
461 iseq $blah, 45;
3568d838 462
84281c31
A
463 $blah = 12;
464 /(?{$blah = 45})/;
465 iseq $blah, 45;
466 }
3568d838 467
84281c31
A
468 {
469 local $Message = "Pos checks";
470 my $x = 'banana';
471 $x =~ /.a/g;
472 iseq pos ($x), 2;
3568d838 473
84281c31
A
474 $x =~ /.z/gc;
475 iseq pos ($x), 2;
3568d838 476
84281c31
A
477 sub f {
478 my $p = $_[0];
479 return $p;
480 }
3568d838 481
84281c31
A
482 $x =~ /.a/g;
483 iseq f (pos ($x)), 4;
484 }
3568d838 485
84281c31
A
486 {
487 local $Message = 'Checking $^R';
488 our $x = $^R = 67;
489 'foot' =~ /foo(?{$x = 12; 75})[t]/;
490 iseq $^R, 75;
491
492 $x = $^R = 67;
493 'foot' =~ /foo(?{$x = 12; 75})[xy]/;
494 ok $^R eq '67' && $x eq '12';
495
496 $x = $^R = 67;
497 'foot' =~ /foo(?{ $^R + 12 })((?{ $x = 12; $^R + 17 })[xy])?/;
498 ok $^R eq '79' && $x eq '12';
499 }
3568d838 500
84281c31 501 {
fb85c044
KW
502 iseq qr/\b\v$/i, '(?^i:\b\v$)', 'qr/\b\v$/i';
503 iseq qr/\b\v$/s, '(?^s:\b\v$)', 'qr/\b\v$/s';
504 iseq qr/\b\v$/m, '(?^m:\b\v$)', 'qr/\b\v$/m';
505 iseq qr/\b\v$/x, '(?^x:\b\v$)', 'qr/\b\v$/x';
9de15fec 506 iseq qr/\b\v$/xism, '(?^msix:\b\v$)', 'qr/\b\v$/xism';
fb85c044 507 iseq qr/\b\v$/, '(?^:\b\v$)', 'qr/\b\v$/';
84281c31 508 }
3568d838 509
9de15fec
KW
510 { # Test that charset modifier work, and are interpolated
511 iseq qr/\b\v$/, '(?^:\b\v$)', 'Verify no locale, no unicode_strings gives default modifier';
512 iseq qr/(?l:\b\v$)/, '(?^:(?l:\b\v$))', 'Verify infix l modifier compiles';
513 iseq qr/(?u:\b\v$)/, '(?^:(?u:\b\v$))', 'Verify infix u modifier compiles';
514 iseq qr/(?l)\b\v$/, '(?^:(?l)\b\v$)', 'Verify (?l) compiles';
515 iseq qr/(?u)\b\v$/, '(?^:(?u)\b\v$)', 'Verify (?u) compiles';
516
517 my $dual = qr/\b\v$/;
518 use locale;
519 my $locale = qr/\b\v$/;
520 iseq $locale, '(?^l:\b\v$)', 'Verify has l modifier when compiled under use locale';
521 no locale;
522
523 use feature 'unicode_strings';
524 my $unicode = qr/\b\v$/;
525 iseq $unicode, '(?^u:\b\v$)', 'Verify has u modifier when compiled under unicode_strings';
526 iseq qr/abc$dual/, '(?^u:abc(?^:\b\v$))', 'Verify retains d meaning when interpolated under locale';
527 iseq qr/abc$locale/, '(?^u:abc(?^l:\b\v$))', 'Verify retains l when interpolated under unicode_strings';
528
529 no feature 'unicode_strings';
530 iseq qr/abc$locale/, '(?^:abc(?^l:\b\v$))', 'Verify retains l when interpolated outside locale and unicode strings';
531 iseq qr/def$unicode/, '(?^:def(?^u:\b\v$))', 'Verify retains u when interpolated outside locale and unicode strings';
532
533 use locale;
534 iseq qr/abc$dual/, '(?^l:abc(?^:\b\v$))', 'Verify retains d meaning when interpolated under locale';
535 iseq qr/abc$unicode/, '(?^l:abc(?^u:\b\v$))', 'Verify retains u when interpolated under locale';
536 }
537
3568d838 538
84281c31
A
539 {
540 local $Message = "Look around";
541 $_ = 'xabcx';
542 SKIP:
543 foreach my $ans ('', 'c') {
544 ok /(?<=(?=a)..)((?=c)|.)/g or skip "Match failed", 1;
545 iseq $1, $ans;
546 }
547 }
3568d838 548
84281c31
A
549 {
550 local $Message = "Empty clause";
551 $_ = 'a';
552 foreach my $ans ('', 'a', '') {
553 ok /^|a|$/g or skip "Match failed", 1;
554 iseq $&, $ans;
555 }
556 }
3568d838 557
84281c31
A
558 {
559 local $Message = "Prefixify";
560 sub prefixify {
561 SKIP: {
562 my ($v, $a, $b, $res) = @_;
563 ok $v =~ s/\Q$a\E/$b/ or skip "Match failed", 1;
564 iseq $v, $res;
565 }
566 }
3568d838 567
84281c31
A
568 prefixify ('/a/b/lib/arch', "/a/b/lib", 'X/lib', 'X/lib/arch');
569 prefixify ('/a/b/man/arch', "/a/b/man", 'X/man', 'X/man/arch');
570 }
3568d838 571
84281c31
A
572 {
573 $_ = 'var="foo"';
574 /(\")/;
575 ok $1 && /$1/, "Capture a quote";
576 }
3568d838 577
84281c31 578 {
84281c31
A
579 no warnings 'closure';
580 local $Message = '(?{ $var } refers to package vars';
581 package aa;
582 our $c = 2;
583 $::c = 3;
584 '' =~ /(?{ $c = 4 })/;
585 main::iseq $c, 4;
586 main::iseq $::c, 3;
587 }
3568d838 588
84281c31
A
589 {
590 must_die 'q(a:[b]:) =~ /[x[:foo:]]/',
591 'POSIX class \[:[^:]+:\] unknown in regex',
592 'POSIX class [: :] must have valid name';
593
594 for my $d (qw [= .]) {
595 must_die "/[[${d}foo${d}]]/",
596 "\QPOSIX syntax [$d $d] is reserved for future extensions",
597 "POSIX syntax [[$d $d]] is an error";
598 }
599 }
3568d838 600
3568d838 601
84281c31
A
602 {
603 # test if failure of patterns returns empty list
604 local $Message = "Failed pattern returns empty list";
605 $_ = 'aaa';
606 @_ = /bbb/;
607 iseq "@_", "";
3568d838 608
84281c31
A
609 @_ = /bbb/g;
610 iseq "@_", "";
a72deede 611
84281c31
A
612 @_ = /(bbb)/;
613 iseq "@_", "";
a72deede 614
84281c31
A
615 @_ = /(bbb)/g;
616 iseq "@_", "";
617 }
a72deede 618
0f289c68 619
84281c31
A
620 {
621 local $Message = '@- and @+ tests';
622
623 /a(?=.$)/;
624 iseq $#+, 0;
625 iseq $#-, 0;
626 iseq $+ [0], 2;
627 iseq $- [0], 1;
628 ok !defined $+ [1] && !defined $- [1] &&
629 !defined $+ [2] && !defined $- [2];
630
631 /a(a)(a)/;
632 iseq $#+, 2;
633 iseq $#-, 2;
634 iseq $+ [0], 3;
635 iseq $- [0], 0;
636 iseq $+ [1], 2;
637 iseq $- [1], 1;
638 iseq $+ [2], 3;
639 iseq $- [2], 2;
640 ok !defined $+ [3] && !defined $- [3] &&
641 !defined $+ [4] && !defined $- [4];
642
54a4274e
PM
643 # Exists has a special check for @-/@+ - bug 45147
644 ok exists $-[0];
645 ok exists $+[0];
646 ok exists $-[2];
647 ok exists $+[2];
648 ok !exists $-[3];
649 ok !exists $+[3];
650 ok exists $-[-1];
651 ok exists $+[-1];
652 ok exists $-[-3];
653 ok exists $+[-3];
654 ok !exists $-[-4];
655 ok !exists $+[-4];
84281c31
A
656
657 /.(a)(b)?(a)/;
658 iseq $#+, 3;
659 iseq $#-, 3;
660 iseq $+ [1], 2;
661 iseq $- [1], 1;
662 iseq $+ [3], 3;
663 iseq $- [3], 2;
664 ok !defined $+ [2] && !defined $- [2] &&
665 !defined $+ [4] && !defined $- [4];
666
667
668 /.(a)/;
669 iseq $#+, 1;
670 iseq $#-, 1;
671 iseq $+ [0], 2;
672 iseq $- [0], 0;
673 iseq $+ [1], 2;
674 iseq $- [1], 1;
675 ok !defined $+ [2] && !defined $- [2] &&
676 !defined $+ [3] && !defined $- [3];
677
678 /.(a)(ba*)?/;
679 iseq $#+, 2;
680 iseq $#-, 1;
681 }
a72deede 682
a72deede 683
84281c31
A
684 {
685 local $DiePattern = '^Modification of a read-only value attempted';
686 local $Message = 'Elements of @- and @+ are read-only';
687 must_die '$+[0] = 13';
688 must_die '$-[0] = 13';
689 must_die '@+ = (7, 6, 5)';
690 must_die '@- = qw (foo bar)';
691 }
a72deede 692
a72deede 693
84281c31
A
694 {
695 local $Message = '\G testing';
696 $_ = 'aaa';
697 pos = 1;
698 my @a = /\Ga/g;
699 iseq "@a", "a a";
700
701 my $str = 'abcde';
702 pos $str = 2;
703 ok $str !~ /^\G/;
704 ok $str !~ /^.\G/;
705 ok $str =~ /^..\G/;
706 ok $str !~ /^...\G/;
707 ok $str =~ /\G../ && $& eq 'cd';
708
709 local $TODO = $running_as_thread;
710 ok $str =~ /.\G./ && $& eq 'bc';
711 }
a72deede 712
569b5e07 713
84281c31
A
714 {
715 local $Message = 'pos inside (?{ })';
716 my $str = 'abcde';
717 our ($foo, $bar);
718 ok $str =~ /b(?{$foo = $_; $bar = pos})c/;
719 iseq $foo, $str;
720 iseq $bar, 2;
721 ok !defined pos ($str);
722
723 undef $foo;
724 undef $bar;
725 pos $str = undef;
726 ok $str =~ /b(?{$foo = $_; $bar = pos})c/g;
727 iseq $foo, $str;
728 iseq $bar, 2;
729 iseq pos ($str), 3;
730
731 $_ = $str;
732 undef $foo;
733 undef $bar;
734 ok /b(?{$foo = $_; $bar = pos})c/;
735 iseq $foo, $str;
736 iseq $bar, 2;
737
738 undef $foo;
739 undef $bar;
740 ok /b(?{$foo = $_; $bar = pos})c/g;
741 iseq $foo, $str;
742 iseq $bar, 2;
743 iseq pos, 3;
744
745 undef $foo;
746 undef $bar;
747 pos = undef;
748 1 while /b(?{$foo = $_; $bar = pos})c/g;
749 iseq $foo, $str;
750 iseq $bar, 2;
751 ok !defined pos;
752
753 undef $foo;
754 undef $bar;
755 $_ = 'abcde|abcde';
756 ok s/b(?{$foo = $_; $bar = pos})c/x/g;
757 iseq $foo, 'abcde|abcde';
758 iseq $bar, 8;
759 iseq $_, 'axde|axde';
760
761 # List context:
762 $_ = 'abcde|abcde';
763 our @res;
764 () = /([ace]).(?{push @res, $1,$2})([ce])(?{push @res, $1,$2})/g;
765 @res = map {defined $_ ? "'$_'" : 'undef'} @res;
766 iseq "@res", "'a' undef 'a' 'c' 'e' undef 'a' undef 'a' 'c'";
767
768 @res = ();
769 () = /([ace]).(?{push @res, $`,$&,$'})([ce])(?{push @res, $`,$&,$'})/g;
770 @res = map {defined $_ ? "'$_'" : 'undef'} @res;
771 iseq "@res", "'' 'ab' 'cde|abcde' " .
772 "'' 'abc' 'de|abcde' " .
773 "'abcd' 'e|' 'abcde' " .
774 "'abcde|' 'ab' 'cde' " .
775 "'abcde|' 'abc' 'de'" ;
776 }
f33976b4 777
cce850e4 778
84281c31
A
779 {
780 local $Message = '\G anchor checks';
781 my $foo = 'aabbccddeeffgg';
782 pos ($foo) = 1;
783 {
784 local $TODO = $running_as_thread;
785 no warnings 'uninitialized';
786 ok $foo =~ /.\G(..)/g;
787 iseq $1, 'ab';
cce850e4 788
84281c31
A
789 pos ($foo) += 1;
790 ok $foo =~ /.\G(..)/g;
791 iseq $1, 'cc';
cce850e4 792
84281c31
A
793 pos ($foo) += 1;
794 ok $foo =~ /.\G(..)/g;
795 iseq $1, 'de';
cce850e4 796
84281c31
A
797 ok $foo =~ /\Gef/g;
798 }
cce850e4 799
84281c31
A
800 undef pos $foo;
801 ok $foo =~ /\G(..)/g;
802 iseq $1, 'aa';
cce850e4 803
84281c31
A
804 ok $foo =~ /\G(..)/g;
805 iseq $1, 'bb';
cce850e4 806
84281c31
A
807 pos ($foo) = 5;
808 ok $foo =~ /\G(..)/g;
809 iseq $1, 'cd';
810 }
cce850e4 811
cce850e4 812
84281c31
A
813 {
814 $_ = '123x123';
815 my @res = /(\d*|x)/g;
816 local $" = '|';
817 iseq "@res", "123||x|123|", "0 match in alternation";
818 }
cce850e4 819
d9f424b2 820
84281c31
A
821 {
822 local $Message = "Match against temporaries (created via pp_helem())" .
823 " is safe";
824 ok {foo => "bar\n" . $^X} -> {foo} =~ /^(.*)\n/g;
825 iseq $1, "bar";
826 }
75685a94 827
d9f424b2 828
84281c31
A
829 {
830 local $Message = 'package $i inside (?{ }), ' .
831 'saved substrings and changing $_';
832 our @a = qw [foo bar];
833 our @b = ();
834 s/(\w)(?{push @b, $1})/,$1,/g for @a;
835 iseq "@b", "f o o b a r";
836 iseq "@a", ",f,,o,,o, ,b,,a,,r,";
837
838 local $Message = 'lexical $i inside (?{ }), ' .
839 'saved substrings and changing $_';
840 no warnings 'closure';
841 my @c = qw [foo bar];
842 my @d = ();
843 s/(\w)(?{push @d, $1})/,$1,/g for @c;
844 iseq "@d", "f o o b a r";
845 iseq "@c", ",f,,o,,o, ,b,,a,,r,";
d9f424b2
JH
846 }
847
d9f424b2 848
84281c31
A
849 {
850 local $Message = 'Brackets';
851 our $brackets;
852 $brackets = qr {
853 { (?> [^{}]+ | (??{ $brackets }) )* }
854 }x;
855
856 ok "{{}" =~ $brackets;
857 iseq $&, "{}";
858 ok "something { long { and } hairy" =~ $brackets;
859 iseq $&, "{ and }";
860 ok "something { long { and } hairy" =~ m/((??{ $brackets }))/;
861 iseq $&, "{ and }";
862 }
a4c04bdc 863
e2d8ce26 864
84281c31
A
865 {
866 $_ = "a-a\nxbb";
867 pos = 1;
868 nok m/^-.*bb/mg, '$_ = "a-a\nxbb"; m/^-.*bb/mg';
869 }
a4c04bdc 870
a4c04bdc 871
84281c31
A
872 {
873 local $Message = '\G anchor checks';
874 my $text = "aaXbXcc";
875 pos ($text) = 0;
876 ok $text !~ /\GXb*X/g;
877 }
a4c04bdc 878
a4c04bdc 879
84281c31
A
880 {
881 $_ = "xA\n" x 500;
882 nok /^\s*A/m, '$_ = "xA\n" x 500; /^\s*A/m"';
a4c04bdc 883
84281c31
A
884 my $text = "abc dbf";
885 my @res = ($text =~ /.*?(b).*?\b/g);
886 iseq "@res", "b b", '\b is not special';
987aaf07 887 }
a4c04bdc 888
a4c04bdc 889
84281c31
A
890 {
891 local $Message = '\S, [\S], \s, [\s]';
892 my @a = map chr, 0 .. 255;
9d45b377
YO
893 my @b = grep m/\S/, @a;
894 my @c = grep m/[^\s]/, @a;
84281c31
A
895 iseq "@b", "@c";
896
897 @b = grep /\S/, @a;
898 @c = grep /[\S]/, @a;
899 iseq "@b", "@c";
900
901 @b = grep /\s/, @a;
902 @c = grep /[^\S]/, @a;
903 iseq "@b", "@c";
904
905 @b = grep /\s/, @a;
906 @c = grep /[\s]/, @a;
907 iseq "@b", "@c";
908 }
909 {
910 local $Message = '\D, [\D], \d, [\d]';
911 my @a = map chr, 0 .. 255;
912 my @b = grep /\D/, @a;
913 my @c = grep /[^\d]/, @a;
914 iseq "@b", "@c";
915
916 @b = grep /\D/, @a;
917 @c = grep /[\D]/, @a;
918 iseq "@b", "@c";
919
920 @b = grep /\d/, @a;
921 @c = grep /[^\D]/, @a;
922 iseq "@b", "@c";
923
924 @b = grep /\d/, @a;
925 @c = grep /[\d]/, @a;
926 iseq "@b", "@c";
927 }
928 {
929 local $Message = '\W, [\W], \w, [\w]';
930 my @a = map chr, 0 .. 255;
931 my @b = grep /\W/, @a;
932 my @c = grep /[^\w]/, @a;
933 iseq "@b", "@c";
934
935 @b = grep /\W/, @a;
936 @c = grep /[\W]/, @a;
937 iseq "@b", "@c";
938
939 @b = grep /\w/, @a;
940 @c = grep /[^\W]/, @a;
941 iseq "@b", "@c";
942
943 @b = grep /\w/, @a;
944 @c = grep /[\w]/, @a;
945 iseq "@b", "@c";
946 }
a4c04bdc 947
a4c04bdc 948
84281c31
A
949 {
950 # see if backtracking optimization works correctly
951 local $Message = 'Backtrack optimization';
952 ok "\n\n" =~ /\n $ \n/x;
953 ok "\n\n" =~ /\n* $ \n/x;
954 ok "\n\n" =~ /\n+ $ \n/x;
955 ok "\n\n" =~ /\n? $ \n/x;
956 ok "\n\n" =~ /\n*? $ \n/x;
957 ok "\n\n" =~ /\n+? $ \n/x;
958 ok "\n\n" =~ /\n?? $ \n/x;
959 ok "\n\n" !~ /\n*+ $ \n/x;
960 ok "\n\n" !~ /\n++ $ \n/x;
961 ok "\n\n" =~ /\n?+ $ \n/x;
962 }
a4c04bdc 963
a4c04bdc 964
84281c31
A
965 {
966 package S;
967 use overload '""' => sub {'Object S'};
968 sub new {bless []}
0f289c68 969
9d45b377 970 local $::Message = "Ref stringification";
84281c31
A
971 ::ok do { \my $v} =~ /^SCALAR/, "Scalar ref stringification";
972 ::ok do {\\my $v} =~ /^REF/, "Ref ref stringification";
973 ::ok [] =~ /^ARRAY/, "Array ref stringification";
974 ::ok {} =~ /^HASH/, "Hash ref stringification";
975 ::ok 'S' -> new =~ /^Object S/, "Object stringification";
976 }
a4c04bdc 977
a4c04bdc 978
84281c31
A
979 {
980 local $Message = "Test result of match used as match";
981 ok 'a1b' =~ ('xyz' =~ /y/);
982 iseq $`, 'a';
983 ok 'a1b' =~ ('xyz' =~ /t/);
984 iseq $`, 'a';
985 }
a4c04bdc 986
a4c04bdc 987
84281c31
A
988 {
989 local $Message = '"1" is not \s';
990 may_not_warn sub {ok ("1\n" x 102) !~ /^\s*\n/m};
991 }
a4c04bdc 992
a4c04bdc 993
84281c31
A
994 {
995 local $Message = '\s, [[:space:]] and [[:blank:]]';
996 my %space = (spc => " ",
997 tab => "\t",
998 cr => "\r",
999 lf => "\n",
1000 ff => "\f",
1001 # There's no \v but the vertical tabulator seems miraculously
1002 # be 11 both in ASCII and EBCDIC.
1003 vt => chr(11),
1004 false => "space");
1005
1006 my @space0 = sort grep {$space {$_} =~ /\s/ } keys %space;
1007 my @space1 = sort grep {$space {$_} =~ /[[:space:]]/} keys %space;
1008 my @space2 = sort grep {$space {$_} =~ /[[:blank:]]/} keys %space;
1009
1010 iseq "@space0", "cr ff lf spc tab";
1011 iseq "@space1", "cr ff lf spc tab vt";
1012 iseq "@space2", "spc tab";
1013 }
a4c04bdc 1014
ff3f963a
KW
1015 {
1016 use charnames ":full";
1017 local $Message = 'Delayed interpolation of \N';
1018 my $r1 = qr/\N{THAI CHARACTER SARA I}/;
1019 my $s1 = "\x{E34}\x{E34}\x{E34}\x{E34}";
1020
1021 # Bug #56444
1022 ok $s1 =~ /$r1+/, 'my $r1 = qr/\N{THAI CHARACTER SARA I}/; my $s1 = "\x{E34}\x{E34}\x{E34}\x{E34}; $s1 =~ /$r1+/';
1023
1024 # Bug #62056
1025 ok "${s1}A" =~ m/$s1\N{LATIN CAPITAL LETTER A}/, '"${s1}A" =~ m/$s1\N{LATIN CAPITAL LETTER A}/';
1026
1027 ok "abbbbc" =~ m/\N{1}/ && $& eq "a", '"abbbbc" =~ m/\N{1}/ && $& eq "a"';
1028 ok "abbbbc" =~ m/\N{3,4}/ && $& eq "abbb", '"abbbbc" =~ m/\N{3,4}/ && $& eq "abbb"';
1029 }
1030
37820adc
KW
1031 {
1032 use charnames ":full";
1033 local $Message = '[perl #74982] Period coming after \N{}';
1034 ok "\x{ff08}." =~ m/\N{FULLWIDTH LEFT PARENTHESIS}./ && $& eq "\x{ff08}.";
1035 ok "\x{ff08}." =~ m/[\N{FULLWIDTH LEFT PARENTHESIS}]./ && $& eq "\x{ff08}.";
1036 }
c9415951
YO
1037 {
1038 my $n= 50;
1039 # this must be a high number and go from 0 to N, as the bug we are looking for doesnt
1040 # seem to be predictable. Slight changes to the test make it fail earlier or later.
1041 foreach my $i (0 .. $n)
1042 {
1043 my $str= "\n" x $i;
1044 ok $str=~/.*\z/, "implict MBOL check string disable does not break things length=$i";
1045 }
1046 }
92f3d482
YO
1047 {
1048 # we are actually testing that we dont die when executing these patterns
1049 use utf8;
1050 my $e = "Böck";
1051 ok(utf8::is_utf8($e),"got a unicode string - rt75680");
1052
1053 ok($e !~ m/.*?[x]$/, "unicode string against /.*?[x]\$/ - rt75680");
1054 ok($e !~ m/.*?\p{Space}$/i, "unicode string against /.*?\\p{space}\$/i - rt75680");
1055 ok($e !~ m/.*?[xyz]$/, "unicode string against /.*?[xyz]\$/ - rt75680");
1056 ok($e !~ m/(.*?)[,\p{isSpace}]+((?:\p{isAlpha}[\p{isSpace}\.]{1,2})+)\p{isSpace}*$/, "unicode string against big pattern - rt75680");
1057 }
1058 {
1059 # we are actually testing that we dont die when executing these patterns
1060 my $e = "B\x{f6}ck";
1061 ok(!utf8::is_utf8($e), "got a latin string - rt75680");
1062
1063 ok($e !~ m/.*?[x]$/, "latin string against /.*?[x]\$/ - rt75680");
1064 ok($e !~ m/.*?\p{Space}$/i, "latin string against /.*?\\p{space}\$/i - rt75680");
1065 ok($e !~ m/.*?[xyz]$/,"latin string against /.*?[xyz]\$/ - rt75680");
1066 ok($e !~ m/(.*?)[,\p{isSpace}]+((?:\p{isAlpha}[\p{isSpace}\.]{1,2})+)\p{isSpace}*$/,"latin string against big pattern - rt75680");
1067 }
c920e018
A
1068
1069 {
1070 #
1071 # Tests for bug 77414.
1072 #
1073
1074 local $Message = '\p property after empty * match';
1075 {
1076 local $TODO = "Bug 77414";
1077 ok "1" =~ /\s*\pN/;
1078 ok "-" =~ /\s*\p{Dash}/;
1079 ok " " =~ /\w*\p{Blank}/;
1080 }
1081
1082 ok "1" =~ /\s*\pN+/;
1083 ok "-" =~ /\s*\p{Dash}{1}/;
1084 ok " " =~ /\w*\p{Blank}{1,4}/;
1085
1086 }
1087
7c17ea2f
KW
1088 SKIP: { # Some constructs with Latin1 characters cause a utf8 string not
1089 # to match itself in non-utf8
1090 if ($IS_EBCDIC) {
1091 skip "Needs to be customized to run on EBCDIC", 6;
1092 }
634c83a2
KW
1093 my $c = "\xc0";
1094 my $pattern = my $utf8_pattern = qr/((\xc0)+,?)/;
1095 utf8::upgrade($utf8_pattern);
1096 ok $c =~ $pattern, "\\xc0 =~ $pattern; Neither pattern nor target utf8";
d4e0b827 1097 ok $c =~ /$pattern/i, "\\xc0 =~ /$pattern/i; Neither pattern nor target utf8";
634c83a2 1098 ok $c =~ $utf8_pattern, "\\xc0 =~ $pattern; pattern utf8, target not";
d4e0b827 1099 ok $c =~ /$utf8_pattern/i, "\\xc0 =~ /$pattern/i; pattern utf8, target not";
634c83a2
KW
1100 utf8::upgrade($c);
1101 ok $c =~ $pattern, "\\xc0 =~ $pattern; target utf8, pattern not";
d4e0b827 1102 ok $c =~ /$pattern/i, "\\xc0 =~ /$pattern/i; target utf8, pattern not";
634c83a2 1103 ok $c =~ $utf8_pattern, "\\xc0 =~ $pattern; Both target and pattern utf8";
d4e0b827 1104 ok $c =~ /$utf8_pattern/i, "\\xc0 =~ /$pattern/i; Both target and pattern utf8";
634c83a2
KW
1105 }
1106
8cc86590
KW
1107 SKIP: { # Make sure can override the formatting
1108 if ($IS_EBCDIC) {
1109 skip "Needs to be customized to run on EBCDIC", 2;
1110 }
1111 use feature 'unicode_strings';
1112 ok "\xc0" =~ /\w/, 'Under unicode_strings: "\xc0" =~ /\w/';
1113 ok "\xc0" !~ /(?d:\w)/, 'Under unicode_strings: "\xc0" !~ /(?d:\w)/';
1114 }
1115
704f71be
B
1116 {
1117 # Test that a regex followed by an operator and/or a statement modifier work
1118 # These tests use string-eval so that it reports a clean error when it fails
1119 # (without the string eval the test script might be unparseable)
1120
1121 # Note: these test check the behaviour that currently is valid syntax
1122 # If a new regex modifier is added and a test fails then there is a backwards-compatibilty issue
1123 # Note-2: a new deprecate warning was added for this with commit e6897b1a5db0410e387ccbf677e89fc4a1d8c97a
1124 # which indicate that this syntax will be removed in 5.16.
1125 # When this happens the tests can be removed
1126
1127 no warnings 'syntax';
1128 iseq( eval q#my $r = "a" =~ m/a/lt 2;"eval_ok $r"#, "eval_ok 1", "regex (m//) followed by lt");
1129 iseq( eval q#my $r = "a" =~ m/a/le 1;"eval_ok $r"#, "eval_ok 1", "regex (m//) followed by le");
1130 iseq( eval q#my $r = "a" =~ m/a/eq 1;"eval_ok $r"#, "eval_ok 1", "regex (m//) followed by eq");
1131 iseq( eval q#my $r = "a" =~ m/a/ne 0;"eval_ok $r"#, "eval_ok 1", "regex (m//) followed by ne");
1132 iseq( eval q#my $r = "a" =~ m/a/and 1;"eval_ok $r"#, "eval_ok 1", "regex (m//) followed by and");
1133 iseq( eval q#my $r = "a" =~ m/a/unless 0;"eval_ok $r"#, "eval_ok 1", "regex (m//) followed by unless");
1134 iseq( eval q#my $c = 1; my $r; $r = "a" =~ m/a/while $c--;"eval_ok $r"#, "eval_ok 1", "regex (m//) followed by while");
1135 iseq( eval q#my $c = 0; my $r; $r = "a" =~ m/a/until $c++;"eval_ok $r"#, "eval_ok 1", "regex (m//) followed by until");
1136 iseq( eval q#my $r; $r = "a" =~ m/a/for 1;"eval_ok $r"#, "eval_ok 1", "regex (m//) followed by for");
1137 iseq( eval q#my $r; $r = "a" =~ m/a/foreach 1;"eval_ok $r"#, "eval_ok 1", "regex (m//) followed by foreach");
1138
1139 iseq( eval q#my $t = "a"; my $r = $t =~ s/a//lt 2;"eval_ok $r"#, "eval_ok 1", "regex (s///) followed by lt");
1140 iseq( eval q#my $t = "a"; my $r = $t =~ s/a//le 1;"eval_ok $r"#, "eval_ok 1", "regex (s///) followed by le");
1141 iseq( eval q#my $t = "a"; my $r = $t =~ s/a//ne 0;"eval_ok $r"#, "eval_ok 1", "regex (s///) followed by ne");
1142 iseq( eval q#my $t = "a"; my $r = $t =~ s/a//and 1;"eval_ok $r"#, "eval_ok 1", "regex (s///) followed by and");
1143 iseq( eval q#my $t = "a"; my $r = $t =~ s/a//unless 0;"eval_ok $r"#, "eval_ok 1", "regex (s///) followed by unless");
1144
1145 iseq( eval q#my $c = 1; my $r; my $t = "a"; $r = $t =~ s/a//while $c--;"eval_ok $r"#, "eval_ok 1", "regex (s///) followed by while");
1146 iseq( eval q#my $c = 0; my $r; my $t = "a"; $r = $t =~ s/a//until $c++;"eval_ok $r"#, "eval_ok 1", "regex (s///) followed by until");
1147 iseq( eval q#my $r; my $t = "a"; $r = $t =~ s/a//for 1;"eval_ok $r"#, "eval_ok 1", "regex (s///) followed by for");
1148 iseq( eval q#my $r; my $t = "a"; $r = $t =~ s/a//for 1;"eval_ok $r"#, "eval_ok 1", "regex (s///) followed by foreach");
1149 }
1150
5b6010b3
YO
1151 {
1152 my $str= "\x{100}";
1153 chop $str;
1154 my $qr= qr/$str/;
1155 iseq( "$qr", "(?^:)", "Empty pattern qr// stringifies to (?^:) with unicode flag enabled - Bug #80212" );
1156 $str= "";
1157 $qr= qr/$str/;
1158 iseq( "$qr", "(?^:)", "Empty pattern qr// stringifies to (?^:) with unicode flag disabled - Bug #80212" )
1159
1160 }
1161
72aa120d
KW
1162 {
1163 local $TODO = "[perl #38133]";
1164
1165 "A" =~ /(((?:A))?)+/;
1166 my $first = $2;
1167
1168 "A" =~ /(((A))?)+/;
1169 my $second = $2;
1170
1171 iseq($first, $second);
1172 }
1173
84281c31
A
1174} # End of sub run_tests
1175
11761;