3 # This is a home for regular expression tests that don't fit into
4 # the format supported by re/regexp.t. If you want to add a test
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.
21 @INC = ('../lib','.');
22 do "re/ReTest.pl" or die $@;
26 plan tests => 402; # Update this when adding/deleting tests.
28 run_tests() unless caller;
39 ok $x =~ /^abc/, qq ["$x" =~ /^abc/];
40 ok $x !~ /^def/, qq ["$x" !~ /^def/];
42 # used to be a test for $*
43 ok $x =~ /^def/m, qq ["$x" =~ /^def/m];
45 nok $x =~ /^xxx/, qq ["$x" =~ /^xxx/];
46 nok $x !~ /^abc/, qq ["$x" !~ /^abc/];
48 ok $x =~ /def/, qq ["$x" =~ /def/];
49 nok $x !~ /def/, qq ["$x" !~ /def/];
51 ok $x !~ /.def/, qq ["$x" !~ /.def/];
52 nok $x =~ /.def/, qq ["$x" =~ /.def/];
54 ok $x =~ /\ndef/, qq ["$x" =~ /\ndef/];
55 nok $x !~ /\ndef/, qq ["$x" !~ /\ndef/];
60 ok /^([0-9][0-9]*)/, qq [\$_ = '$_'; /^([0-9][0-9]*)/];
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+/];
71 ok /a+b?c+/, qq [\$_ = '$_'; /a+b?c+/];
72 ok /a*b?c*/, qq [\$_ = '$_'; /a*b?c*/];
75 ok /a*b?c*/, qq [\$_ = '$_'; /a*b?c*/];
76 nok /a*b+c*/, qq [\$_ = '$_'; /a*b+c*/];
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 [\$_ = '$_'; /^\$_\$/];
86 # used to be a test for $*
87 ok "ab\ncd\n" =~ /^cd/m, qq ["ab\ncd\n" =~ /^cd/m];
91 our %XXX = map {($_ => $_)} 123, 234, 345;
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;
113 ok !keys %XXX, "%XXX is empty";
119 local $Message = "Test empty pattern";
134 no warnings 'uninitialized';
144 local $Message = q !Check $`, $&, $'!;
146 /def/; # optimized up to cmd
147 iseq "$`:$&:$'", 'abc:def:ghi';
150 /cde/ + 0; # optimized only to spat
151 iseq "$`:$&:$'", 'ab:cde:fghi';
153 /[d][e][f]/; # not optimized
154 iseq "$`:$&:$'", 'abc:def:ghi';
158 $_ = 'now is the {time for all} good men to come to.';
160 iseq $1, 'time for all', "Match braces";
164 local $Message = "{N,M} quantifier";
165 $_ = 'xxx {3,4} yyy zzz';
178 local $Message = "Test /g";
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";
197 iseq "@words", "to:to";
201 iseq "@words", "to:to";
217 my $t1 = my $t2 = my $t3 = my $t4 = my $t5 =
218 my $t6 = my $t7 = my $t8 = my $t9 = 0;
220 for my $iter (1 .. 5) {
231 my $x = "$t1$t2$t3$t4$t5$t6$t7$t8$t9";
232 iseq $x, '505550555', "Test /o";
238 ok "abc" =~ /^abc$|$xyz/, "| after \$";
240 # perl 4.009 says "unmatched ()"
241 local $Message = '$ inside ()';
244 eval '"abc" =~ /a(bc$)|$xyz/; $result = "$&:$1"';
245 iseq $@, "" or skip "eval failed", 1;
246 iseq $result, "abc:bc";
251 local $Message = "Scalar /g";
254 ok /abc/g && $` eq "";
255 ok /abc/g && $` eq "abcfoo";
258 local $Message = "Scalar /gi";
260 ok /ABC/gi && $` eq "";
261 ok /ABC/gi && $` eq "abcfoo";
264 local $Message = "Scalar /g";
266 ok /abc/g && $' eq "fooabcbar";
267 ok /abc/g && $' eq "bar";
271 iseq @x, 2, "/g reset after assignment";
275 local $Message = '/g, \G and pos';
285 local $Message = '(?{ })';
287 'abc' =~ m'a(?{ $out = 2 })b';
291 'abc' =~ m'a(?{ $out = 3 })c';
297 $_ = 'foobar1 bar2 foobar3 barfoobar5 foobar6';
298 my @out = /(?<!foo)bar./g;
299 iseq "@out", 'bar2 barf', "Negative lookbehind";
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.
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.
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/;
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";
332 local $Message = "Long monster";
333 for my $l (125, 140, 250, 270, 300000, 30) { # Ordered to free memory
335 local $Error = "length = $l";
336 ok "ba$a=" =~ /a$a=/;
337 nok "b$a=" =~ /a$a=/;
340 ok "ba$a=" =~ /b(?:a|b)+=/;
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,
353 'ax13876y25677y21378zbc' => 0, # Not followed by [k-o]
354 'ax13876y25677y21378y21378kbc' => 1,
355 'ax13876y25677y21378y21378kcb' => 0, # Not b.
356 'ax13876y25677y21378y21378y21378kbc' => 0, # 5 runs
359 local $Message = "20000 nodes";
361 local $Error = "const-len '$_'";
362 ok !($ans{$_} xor /a(?=([yx]($long_constant_len)){2,4}[k-o]).*b./o);
364 local $Error = "var-len '$_'";
365 ok !($ans{$_} xor /a(?=([yx]($long_var_len)){2,4}[k-o]).*b./o);
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)";
379 (?{ $c = 1 }) # Initialize
381 (?(?{ $c == 0 }) # PREVIOUS iteration was OK, stop the loop
383 ) # Fail: will unwind one iteration back
386 [^()]+ # Match a big chunk
389 ) # Do not try to match subchunks
397 )+ # This may not match with different subblocks
402 ) # Otherwise the chunk 1 may succeed with $c>0
408 push @ans, $res while $res = matchit;
409 iseq "@ans", "1 1 1";
412 iseq "@ans", $expect;
414 local $Message = "Recursion with (??{ })";
416 $matched = qr/\((?:(?>[^()]+)|(??{$matched}))*\)/;
418 @ans = my @ans1 = ();
419 push (@ans, $res), push (@ans1, $&) while $res = m/$matched/g;
421 iseq "@ans", "1 1 1";
422 iseq "@ans1", $expect;
425 iseq "@ans", $expect;
430 ok "abc" =~ /^(??{"a"})b/, '"abc" =~ /^(??{"a"})b/';
434 my @ans = ('a/b' =~ m%(.*/)?(.*)%); # Stack may be bad
435 iseq "@ans", 'a/ b', "Stack may be bad";
439 local $Message = "Eval-group not allowed at runtime";
440 my $code = '{$blah = 45}';
443 ok $@ && $@ =~ /not allowed at runtime/ && $blah == 12;
445 for $code ('{$blah = 45}','=xx') {
447 my $res = eval { "xx" =~ /(?$code)/o };
448 no warnings 'uninitialized';
449 local $Error = "'$@', '$res', '$blah'";
450 if ($code eq '=xx') {
454 ok $@ && $@ =~ /not allowed at runtime/ && $blah == 12;
458 $code = '{$blah = 45}';
469 local $Message = "Pos checks";
483 iseq f (pos ($x)), 4;
487 local $Message = 'Checking $^R';
489 'foot' =~ /foo(?{$x = 12; 75})[t]/;
493 'foot' =~ /foo(?{$x = 12; 75})[xy]/;
494 ok $^R eq '67' && $x eq '12';
497 'foot' =~ /foo(?{ $^R + 12 })((?{ $x = 12; $^R + 17 })[xy])?/;
498 ok $^R eq '79' && $x eq '12';
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';
506 iseq qr/\b\v$/xism, '(?^msix:\b\v$)', 'qr/\b\v$/xism';
507 iseq qr/\b\v$/, '(?^:\b\v$)', 'qr/\b\v$/';
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';
517 my $dual = qr/\b\v$/;
519 my $locale = qr/\b\v$/;
520 iseq $locale, '(?^l:\b\v$)', 'Verify has l modifier when compiled under use locale';
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';
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';
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';
540 local $Message = "Look around";
543 foreach my $ans ('', 'c') {
544 ok /(?<=(?=a)..)((?=c)|.)/g or skip "Match failed", 1;
550 local $Message = "Empty clause";
552 foreach my $ans ('', 'a', '') {
553 ok /^|a|$/g or skip "Match failed", 1;
559 local $Message = "Prefixify";
562 my ($v, $a, $b, $res) = @_;
563 ok $v =~ s/\Q$a\E/$b/ or skip "Match failed", 1;
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');
575 ok $1 && /$1/, "Capture a quote";
579 no warnings 'closure';
580 local $Message = '(?{ $var } refers to package vars';
584 '' =~ /(?{ $c = 4 })/;
590 must_die 'q(a:[b]:) =~ /[x[:foo:]]/',
591 'POSIX class \[:[^:]+:\] unknown in regex',
592 'POSIX class [: :] must have valid name';
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";
603 # test if failure of patterns returns empty list
604 local $Message = "Failed pattern returns empty list";
621 local $Message = '@- and @+ tests';
628 ok !defined $+ [1] && !defined $- [1] &&
629 !defined $+ [2] && !defined $- [2];
640 ok !defined $+ [3] && !defined $- [3] &&
641 !defined $+ [4] && !defined $- [4];
651 ok !defined $+ [2] && !defined $- [2] &&
652 !defined $+ [4] && !defined $- [4];
662 ok !defined $+ [2] && !defined $- [2] &&
663 !defined $+ [3] && !defined $- [3];
672 local $DiePattern = '^Modification of a read-only value attempted';
673 local $Message = 'Elements of @- and @+ are read-only';
674 must_die '$+[0] = 13';
675 must_die '$-[0] = 13';
676 must_die '@+ = (7, 6, 5)';
677 must_die '@- = qw (foo bar)';
682 local $Message = '\G testing';
694 ok $str =~ /\G../ && $& eq 'cd';
696 local $TODO = $running_as_thread;
697 ok $str =~ /.\G./ && $& eq 'bc';
702 local $Message = 'pos inside (?{ })';
705 ok $str =~ /b(?{$foo = $_; $bar = pos})c/;
708 ok !defined pos ($str);
713 ok $str =~ /b(?{$foo = $_; $bar = pos})c/g;
721 ok /b(?{$foo = $_; $bar = pos})c/;
727 ok /b(?{$foo = $_; $bar = pos})c/g;
735 1 while /b(?{$foo = $_; $bar = pos})c/g;
743 ok s/b(?{$foo = $_; $bar = pos})c/x/g;
744 iseq $foo, 'abcde|abcde';
746 iseq $_, 'axde|axde';
751 () = /([ace]).(?{push @res, $1,$2})([ce])(?{push @res, $1,$2})/g;
752 @res = map {defined $_ ? "'$_'" : 'undef'} @res;
753 iseq "@res", "'a' undef 'a' 'c' 'e' undef 'a' undef 'a' 'c'";
756 () = /([ace]).(?{push @res, $`,$&,$'})([ce])(?{push @res, $`,$&,$'})/g;
757 @res = map {defined $_ ? "'$_'" : 'undef'} @res;
758 iseq "@res", "'' 'ab' 'cde|abcde' " .
759 "'' 'abc' 'de|abcde' " .
760 "'abcd' 'e|' 'abcde' " .
761 "'abcde|' 'ab' 'cde' " .
762 "'abcde|' 'abc' 'de'" ;
767 local $Message = '\G anchor checks';
768 my $foo = 'aabbccddeeffgg';
771 local $TODO = $running_as_thread;
772 no warnings 'uninitialized';
773 ok $foo =~ /.\G(..)/g;
777 ok $foo =~ /.\G(..)/g;
781 ok $foo =~ /.\G(..)/g;
788 ok $foo =~ /\G(..)/g;
791 ok $foo =~ /\G(..)/g;
795 ok $foo =~ /\G(..)/g;
802 my @res = /(\d*|x)/g;
804 iseq "@res", "123||x|123|", "0 match in alternation";
809 local $Message = "Match against temporaries (created via pp_helem())" .
811 ok {foo => "bar\n" . $^X} -> {foo} =~ /^(.*)\n/g;
817 local $Message = 'package $i inside (?{ }), ' .
818 'saved substrings and changing $_';
819 our @a = qw [foo bar];
821 s/(\w)(?{push @b, $1})/,$1,/g for @a;
822 iseq "@b", "f o o b a r";
823 iseq "@a", ",f,,o,,o, ,b,,a,,r,";
825 local $Message = 'lexical $i inside (?{ }), ' .
826 'saved substrings and changing $_';
827 no warnings 'closure';
828 my @c = qw [foo bar];
830 s/(\w)(?{push @d, $1})/,$1,/g for @c;
831 iseq "@d", "f o o b a r";
832 iseq "@c", ",f,,o,,o, ,b,,a,,r,";
837 local $Message = 'Brackets';
840 { (?> [^{}]+ | (??{ $brackets }) )* }
843 ok "{{}" =~ $brackets;
845 ok "something { long { and } hairy" =~ $brackets;
847 ok "something { long { and } hairy" =~ m/((??{ $brackets }))/;
855 nok m/^-.*bb/mg, '$_ = "a-a\nxbb"; m/^-.*bb/mg';
860 local $Message = '\G anchor checks';
861 my $text = "aaXbXcc";
863 ok $text !~ /\GXb*X/g;
869 nok /^\s*A/m, '$_ = "xA\n" x 500; /^\s*A/m"';
871 my $text = "abc dbf";
872 my @res = ($text =~ /.*?(b).*?\b/g);
873 iseq "@res", "b b", '\b is not special';
878 local $Message = '\S, [\S], \s, [\s]';
879 my @a = map chr, 0 .. 255;
880 my @b = grep m/\S/, @a;
881 my @c = grep m/[^\s]/, @a;
885 @c = grep /[\S]/, @a;
889 @c = grep /[^\S]/, @a;
893 @c = grep /[\s]/, @a;
897 local $Message = '\D, [\D], \d, [\d]';
898 my @a = map chr, 0 .. 255;
899 my @b = grep /\D/, @a;
900 my @c = grep /[^\d]/, @a;
904 @c = grep /[\D]/, @a;
908 @c = grep /[^\D]/, @a;
912 @c = grep /[\d]/, @a;
916 local $Message = '\W, [\W], \w, [\w]';
917 my @a = map chr, 0 .. 255;
918 my @b = grep /\W/, @a;
919 my @c = grep /[^\w]/, @a;
923 @c = grep /[\W]/, @a;
927 @c = grep /[^\W]/, @a;
931 @c = grep /[\w]/, @a;
937 # see if backtracking optimization works correctly
938 local $Message = 'Backtrack optimization';
939 ok "\n\n" =~ /\n $ \n/x;
940 ok "\n\n" =~ /\n* $ \n/x;
941 ok "\n\n" =~ /\n+ $ \n/x;
942 ok "\n\n" =~ /\n? $ \n/x;
943 ok "\n\n" =~ /\n*? $ \n/x;
944 ok "\n\n" =~ /\n+? $ \n/x;
945 ok "\n\n" =~ /\n?? $ \n/x;
946 ok "\n\n" !~ /\n*+ $ \n/x;
947 ok "\n\n" !~ /\n++ $ \n/x;
948 ok "\n\n" =~ /\n?+ $ \n/x;
954 use overload '""' => sub {'Object S'};
957 local $::Message = "Ref stringification";
958 ::ok do { \my $v} =~ /^SCALAR/, "Scalar ref stringification";
959 ::ok do {\\my $v} =~ /^REF/, "Ref ref stringification";
960 ::ok [] =~ /^ARRAY/, "Array ref stringification";
961 ::ok {} =~ /^HASH/, "Hash ref stringification";
962 ::ok 'S' -> new =~ /^Object S/, "Object stringification";
967 local $Message = "Test result of match used as match";
968 ok 'a1b' =~ ('xyz' =~ /y/);
970 ok 'a1b' =~ ('xyz' =~ /t/);
976 local $Message = '"1" is not \s';
977 may_not_warn sub {ok ("1\n" x 102) !~ /^\s*\n/m};
982 local $Message = '\s, [[:space:]] and [[:blank:]]';
983 my %space = (spc => " ",
988 # There's no \v but the vertical tabulator seems miraculously
989 # be 11 both in ASCII and EBCDIC.
993 my @space0 = sort grep {$space {$_} =~ /\s/ } keys %space;
994 my @space1 = sort grep {$space {$_} =~ /[[:space:]]/} keys %space;
995 my @space2 = sort grep {$space {$_} =~ /[[:blank:]]/} keys %space;
997 iseq "@space0", "cr ff lf spc tab";
998 iseq "@space1", "cr ff lf spc tab vt";
999 iseq "@space2", "spc tab";
1003 use charnames ":full";
1004 local $Message = 'Delayed interpolation of \N';
1005 my $r1 = qr/\N{THAI CHARACTER SARA I}/;
1006 my $s1 = "\x{E34}\x{E34}\x{E34}\x{E34}";
1009 ok $s1 =~ /$r1+/, 'my $r1 = qr/\N{THAI CHARACTER SARA I}/; my $s1 = "\x{E34}\x{E34}\x{E34}\x{E34}; $s1 =~ /$r1+/';
1012 ok "${s1}A" =~ m/$s1\N{LATIN CAPITAL LETTER A}/, '"${s1}A" =~ m/$s1\N{LATIN CAPITAL LETTER A}/';
1014 ok "abbbbc" =~ m/\N{1}/ && $& eq "a", '"abbbbc" =~ m/\N{1}/ && $& eq "a"';
1015 ok "abbbbc" =~ m/\N{3,4}/ && $& eq "abbb", '"abbbbc" =~ m/\N{3,4}/ && $& eq "abbb"';
1019 use charnames ":full";
1020 local $Message = '[perl #74982] Period coming after \N{}';
1021 ok "\x{ff08}." =~ m/\N{FULLWIDTH LEFT PARENTHESIS}./ && $& eq "\x{ff08}.";
1022 ok "\x{ff08}." =~ m/[\N{FULLWIDTH LEFT PARENTHESIS}]./ && $& eq "\x{ff08}.";
1026 # this must be a high number and go from 0 to N, as the bug we are looking for doesnt
1027 # seem to be predictable. Slight changes to the test make it fail earlier or later.
1028 foreach my $i (0 .. $n)
1031 ok $str=~/.*\z/, "implict MBOL check string disable does not break things length=$i";
1035 # we are actually testing that we dont die when executing these patterns
1038 ok(utf8::is_utf8($e),"got a unicode string - rt75680");
1040 ok($e !~ m/.*?[x]$/, "unicode string against /.*?[x]\$/ - rt75680");
1041 ok($e !~ m/.*?\p{Space}$/i, "unicode string against /.*?\\p{space}\$/i - rt75680");
1042 ok($e !~ m/.*?[xyz]$/, "unicode string against /.*?[xyz]\$/ - rt75680");
1043 ok($e !~ m/(.*?)[,\p{isSpace}]+((?:\p{isAlpha}[\p{isSpace}\.]{1,2})+)\p{isSpace}*$/, "unicode string against big pattern - rt75680");
1046 # we are actually testing that we dont die when executing these patterns
1047 my $e = "B\x{f6}ck";
1048 ok(!utf8::is_utf8($e), "got a latin string - rt75680");
1050 ok($e !~ m/.*?[x]$/, "latin string against /.*?[x]\$/ - rt75680");
1051 ok($e !~ m/.*?\p{Space}$/i, "latin string against /.*?\\p{space}\$/i - rt75680");
1052 ok($e !~ m/.*?[xyz]$/,"latin string against /.*?[xyz]\$/ - rt75680");
1053 ok($e !~ m/(.*?)[,\p{isSpace}]+((?:\p{isAlpha}[\p{isSpace}\.]{1,2})+)\p{isSpace}*$/,"latin string against big pattern - rt75680");
1058 # Tests for bug 77414.
1061 local $Message = '\p property after empty * match';
1063 local $TODO = "Bug 77414";
1065 ok "-" =~ /\s*\p{Dash}/;
1066 ok " " =~ /\w*\p{Blank}/;
1069 ok "1" =~ /\s*\pN+/;
1070 ok "-" =~ /\s*\p{Dash}{1}/;
1071 ok " " =~ /\w*\p{Blank}{1,4}/;
1075 { # Some constructs with Latin1 characters cause a utf8 string not to
1076 # match itself in non-utf8
1078 my $pattern = my $utf8_pattern = qr/((\xc0)+,?)/;
1079 utf8::upgrade($utf8_pattern);
1080 ok $c =~ $pattern, "\\xc0 =~ $pattern; Neither pattern nor target utf8";
1081 ok $c =~ /$pattern/i, "\\xc0 =~ /$pattern/i; Neither pattern nor target utf8";
1082 ok $c =~ $utf8_pattern, "\\xc0 =~ $pattern; pattern utf8, target not";
1083 ok $c =~ /$utf8_pattern/i, "\\xc0 =~ /$pattern/i; pattern utf8, target not";
1085 ok $c =~ $pattern, "\\xc0 =~ $pattern; target utf8, pattern not";
1086 ok $c =~ /$pattern/i, "\\xc0 =~ /$pattern/i; target utf8, pattern not";
1087 ok $c =~ $utf8_pattern, "\\xc0 =~ $pattern; Both target and pattern utf8";
1088 ok $c =~ /$utf8_pattern/i, "\\xc0 =~ /$pattern/i; Both target and pattern utf8";
1092 # Test that a regex followed by an operator and/or a statement modifier work
1093 # These tests use string-eval so that it reports a clean error when it fails
1094 # (without the string eval the test script might be unparseable)
1096 # Note: these test check the behaviour that currently is valid syntax
1097 # If a new regex modifier is added and a test fails then there is a backwards-compatibilty issue
1098 # Note-2: a new deprecate warning was added for this with commit e6897b1a5db0410e387ccbf677e89fc4a1d8c97a
1099 # which indicate that this syntax will be removed in 5.16.
1100 # When this happens the tests can be removed
1102 no warnings 'syntax';
1103 iseq( eval q#my $r = "a" =~ m/a/lt 2;"eval_ok $r"#, "eval_ok 1", "regex (m//) followed by lt");
1104 iseq( eval q#my $r = "a" =~ m/a/le 1;"eval_ok $r"#, "eval_ok 1", "regex (m//) followed by le");
1105 iseq( eval q#my $r = "a" =~ m/a/eq 1;"eval_ok $r"#, "eval_ok 1", "regex (m//) followed by eq");
1106 iseq( eval q#my $r = "a" =~ m/a/ne 0;"eval_ok $r"#, "eval_ok 1", "regex (m//) followed by ne");
1107 iseq( eval q#my $r = "a" =~ m/a/and 1;"eval_ok $r"#, "eval_ok 1", "regex (m//) followed by and");
1108 iseq( eval q#my $r = "a" =~ m/a/unless 0;"eval_ok $r"#, "eval_ok 1", "regex (m//) followed by unless");
1109 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");
1110 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");
1111 iseq( eval q#my $r; $r = "a" =~ m/a/for 1;"eval_ok $r"#, "eval_ok 1", "regex (m//) followed by for");
1112 iseq( eval q#my $r; $r = "a" =~ m/a/foreach 1;"eval_ok $r"#, "eval_ok 1", "regex (m//) followed by foreach");
1114 iseq( eval q#my $t = "a"; my $r = $t =~ s/a//lt 2;"eval_ok $r"#, "eval_ok 1", "regex (s///) followed by lt");
1115 iseq( eval q#my $t = "a"; my $r = $t =~ s/a//le 1;"eval_ok $r"#, "eval_ok 1", "regex (s///) followed by le");
1116 iseq( eval q#my $t = "a"; my $r = $t =~ s/a//ne 0;"eval_ok $r"#, "eval_ok 1", "regex (s///) followed by ne");
1117 iseq( eval q#my $t = "a"; my $r = $t =~ s/a//and 1;"eval_ok $r"#, "eval_ok 1", "regex (s///) followed by and");
1118 iseq( eval q#my $t = "a"; my $r = $t =~ s/a//unless 0;"eval_ok $r"#, "eval_ok 1", "regex (s///) followed by unless");
1120 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");
1121 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");
1122 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");
1123 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");
1126 } # End of sub run_tests