3 # This is a home for regular expression tests that don't fit into
4 # the format supported by op/regexp.t. If you want to add a test
5 # that does fit that format, add it to op/re_tests, not here.
16 eval 'use Config'; # Defaults assumed if this fails
20 if ($x =~ /^abc/) {print "ok 1\n";} else {print "not ok 1\n";}
21 if ($x !~ /^def/) {print "ok 2\n";} else {print "not ok 2\n";}
23 # used to be a test for $*
24 if ($x =~ /^def/m) {print "ok 3\n";} else {print "not ok 3\n";}
27 if (/^([0-9][0-9]*)/) {print "ok 4\n";} else {print "not ok 4\n";}
29 if ($x =~ /^xxx/) {print "not ok 5\n";} else {print "ok 5\n";}
30 if ($x !~ /^abc/) {print "not ok 6\n";} else {print "ok 6\n";}
32 if ($x =~ /def/) {print "ok 7\n";} else {print "not ok 7\n";}
33 if ($x !~ /def/) {print "not ok 8\n";} else {print "ok 8\n";}
35 if ($x !~ /.def/) {print "ok 9\n";} else {print "not ok 9\n";}
36 if ($x =~ /.def/) {print "not ok 10\n";} else {print "ok 10\n";}
38 if ($x =~ /\ndef/) {print "ok 11\n";} else {print "not ok 11\n";}
39 if ($x !~ /\ndef/) {print "not ok 12\n";} else {print "ok 12\n";}
42 if (/(a*b*)(c*)/ && $1 eq 'aaabbb' && $2 eq 'ccc') {
47 if (/(a+b+c+)/ && $1 eq 'aaabbbccc') {
53 if (/a+b?c+/) {print "not ok 15\n";} else {print "ok 15\n";}
56 if (/a+b?c+/) {print "ok 16\n";} else {print "not ok 16\n";}
57 if (/a*b+c*/) {print "ok 17\n";} else {print "not ok 17\n";}
60 if (/a*b?c*/) {print "ok 18\n";} else {print "not ok 18\n";}
61 if (/a*b+c*/) {print "not ok 19\n";} else {print "ok 19\n";}
64 if (/bcd|xyz/) {print "ok 20\n";} else {print "not ok 20\n";}
65 if (/xyz|bcd/) {print "ok 21\n";} else {print "not ok 21\n";}
67 if (m|bc/*d|) {print "ok 22\n";} else {print "not ok 22\n";}
69 if (/^$_$/) {print "ok 23\n";} else {print "not ok 23\n";}
71 # used to be a test for $*
72 if ("ab\ncd\n" =~ /^cd/m) {print "ok 24\n";} else {print "not ok 24\n";}
78 @XXX = ('ok 25','not ok 25', 'ok 26','not ok 26','not ok 27');
79 while ($_ = shift(@XXX)) {
80 ?(.*)? && (print $1,"\n");
93 while (($key,$val) = each(%XXX)) {
103 if ($& eq 'xyz') {print "ok 28\n";} else {print "not ok 28\n";}
108 if ($& eq 'xyz') {print "ok 29\n";} else {print "not ok 29\n";}
113 if ($& eq 'xyz') {print "ok 30\n";} else {print "not ok 30\n";}
116 /def/; # optimized up to cmd
117 if ("$`:$&:$'" eq 'abc:def:ghi') {print "ok 31\n";} else {print "not ok 31\n";}
119 /cde/ + 0; # optimized only to spat
120 if ("$`:$&:$'" eq 'ab:cde:fghi') {print "ok 32\n";} else {print "not ok 32\n";}
122 /[d][e][f]/; # not optimized
123 if ("$`:$&:$'" eq 'abc:def:ghi') {print "ok 33\n";} else {print "not ok 33\n";}
125 $_ = 'now is the {time for all} good men to come to.';
127 if ($1 eq 'time for all') {print "ok 34\n";} else {print "not ok 34 $1\n";}
129 $_ = 'xxx {3,4} yyy zzz';
130 print /( {3,4})/ ? "ok 35\n" : "not ok 35\n";
131 print $1 eq ' ' ? "ok 36\n" : "not ok 36\n";
132 print /( {4,})/ ? "not ok 37\n" : "ok 37\n";
133 print /( {2,3}.)/ ? "ok 38\n" : "not ok 38\n";
134 print $1 eq ' y' ? "ok 39\n" : "not ok 39\n";
135 print /(y{2,3}.)/ ? "ok 40\n" : "not ok 40\n";
136 print $1 eq 'yyy ' ? "ok 41\n" : "not ok 41\n";
137 print /x {3,4}/ ? "not ok 42\n" : "ok 42\n";
138 print /^xxx {3,4}/ ? "not ok 43\n" : "ok 43\n";
140 $_ = "now is the time for all good men to come to.";
142 print join(':',@words) eq "now:is:the:time:for:all:good:men:to:come:to"
150 print join(':',@words) eq "now:is:the:time:for:all:good:men:to:come:to"
159 print join(':',@words) eq "to:to"
161 : "not ok 46 `@words'\n";
165 print join(':',@words) eq "to:to"
167 : "not ok 47 `@words'\n";
181 $t1=$t2=$t3=$t4=$t5=$t6=$t7=$t8=$t9=0;
195 $x = "$t1$t2$t3$t4$t5$t6$t7$t8$t9";
196 print $x eq '505550555' ? "ok 48\n" : "not ok 48 $x\n";
199 print "abc" =~ /^abc$|$xyz/ ? "ok 49\n" : "not ok 49\n";
201 # perl 4.009 says "unmatched ()"
202 eval '"abc" =~ /a(bc$)|$xyz/; $result = "$&:$1"';
203 print $@ eq "" ? "ok 50\n" : "not ok 50\n";
204 print $result eq "abc:bc" ? "ok 51\n" : "not ok 51\n";
209 print $` eq "" ? "ok 52\n" : "not ok 52\n" if $x;
211 print $` eq "abcfoo" ? "ok 53\n" : "not ok 53\n" if $x;
213 print $x == 0 ? "ok 54\n" : "not ok 54\n";
216 print $` eq "" ? "ok 55\n" : "not ok 55\n" if $x;
218 print $` eq "abcfoo" ? "ok 56\n" : "not ok 56\n" if $x;
220 print $x == 0 ? "ok 57\n" : "not ok 57\n";
223 print $' eq "fooabcbar" ? "ok 58\n" : "not ok 58\n" if $x;
225 print $' eq "bar" ? "ok 59\n" : "not ok 59\n" if $x;
228 print scalar @x == 2 ? "ok 60\n" : "not ok 60\n";
233 print "not " if (pos $_) != 2;
236 print "not " if defined pos $_;
240 'abc' =~ m'a(?{ $out = 2 })b';
241 print "not " if $out != 2;
245 'abc' =~ m'a(?{ $out = 3 })c';
246 print "not " if $out != 1;
249 $_ = 'foobar1 bar2 foobar3 barfoobar5 foobar6';
250 @out = /(?<!foo)bar./g;
251 print "not " if "@out" ne 'bar2 barf';
254 # Tests which depend on REG_INFTY
255 $reg_infty = defined $Config{reg_infty} ? $Config{reg_infty} : 32767;
256 $reg_infty_m = $reg_infty - 1; $reg_infty_p = $reg_infty + 1;
258 # As well as failing if the pattern matches do unexpected things, the
259 # next three tests will fail if you should have picked up a lower-than-
260 # default value for $reg_infty from Config.pm, but have not.
263 print "not " if eval q(('aaa' =~ /(a{1,$reg_infty_m})/)[0] ne 'aaa') || $@;
267 print "not " if eval q(('a' x $reg_infty_m) !~ /a{$reg_infty_m}/) || $@;
271 print "not " if eval q(('a' x ($reg_infty_m - 1)) =~ /a{$reg_infty_m}/) || $@;
275 eval "'aaa' =~ /a{1,$reg_infty}/";
276 print "not " if $@ !~ m%^\QQuantifier in {,} bigger than%;
279 eval "'aaa' =~ /a{1,$reg_infty_p}/";
281 if $@ !~ m%^\QQuantifier in {,} bigger than%;
285 # Poke a couple more parse failures
287 $context = 'x' x 256;
288 eval qq("${context}y" =~ /(?<=$context)y/);
289 print "not " if $@ !~ m%^\QLookbehind longer than 255 not%;
297 for $l (125, 140, 250, 270, 300000, 30) { # Ordered to free memory
299 print "# length=$l\nnot " unless "ba$a=" =~ /a$a=/;
303 print "not " if "b$a=" =~ /a$a=/;
308 # 20000 nodes, each taking 3 words per string, and 1 per branch
309 $long_constant_len = join '|', 12120 .. 32645;
310 $long_var_len = join '|', 8120 .. 28645;
311 %ans = ( 'ax13876y25677lbc' => 1,
312 'ax13876y25677mcb' => 0, # not b.
313 'ax13876y35677nbc' => 0, # Num too big
314 'ax13876y25677y21378obc' => 1,
315 'ax13876y25677y21378zbc' => 0, # Not followed by [k-o]
316 'ax13876y25677y21378y21378kbc' => 1,
317 'ax13876y25677y21378y21378kcb' => 0, # Not b.
318 'ax13876y25677y21378y21378y21378kbc' => 0, # 5 runs
322 print "# const-len `$_' not => $ans{$_}\nnot "
323 if $ans{$_} xor /a(?=([yx]($long_constant_len)){2,4}[k-o]).*b./o;
326 print "# var-len `$_' not => $ans{$_}\nnot "
327 if $ans{$_} xor /a(?=([yx]($long_var_len)){2,4}[k-o]).*b./o;
332 $_ = " a (bla()) and x(y b((l)u((e))) and b(l(e)e)e";
333 $expect = "(bla()) ((l)u((e))) (l(e)e)";
339 (?{ $c = 1 }) # Initialize
341 (?(?{ $c == 0 }) # PREVIOUS iteration was OK, stop the loop
343 ) # Fail: will unwind one iteration back
346 [^()]+ # Match a big chunk
349 ) # Do not try to match subchunks
357 )+ # This may not match with different subblocks
362 ) # Otherwise the chunk 1 may succeed with $c>0
367 push @ans, $res while $res = matchit;
369 print "# ans='@ans'\n# expect='$expect'\nnot " if "@ans" ne "1 1 1";
375 print "# ans='@ans'\n# expect='$expect'\nnot " if "@ans" ne $expect;
379 print "not " unless "abc" =~ /^(??{"a"})b/;
384 $matched = qr/\((?:(?>[^()]+)|(??{$matched}))*\)/;
387 push(@ans, $res), push(@ans1, $&) while $res = m/$matched/g;
389 print "# ans='@ans'\n# expect='$expect'\nnot " if "@ans" ne "1 1 1";
393 print "# ans1='@ans1'\n# expect='$expect'\nnot " if "@ans1" ne $expect;
399 print "# ans='@ans'\n# expect='$expect'\nnot " if "@ans" ne $expect;
403 @ans = ('a/b' =~ m%(.*/)?(.*)%); # Stack may be bad
404 print "not " if "@ans" ne 'a/ b';
408 $code = '{$blah = 45}';
411 print "not " unless $@ and $@ =~ /not allowed at runtime/ and $blah == 12;
415 for $code ('{$blah = 45}','=xx') {
417 $res = eval { "xx" =~ /(?$code)/o };
418 if ($code eq '=xx') {
419 print "#'$@','$res','$blah'\nnot " unless not $@ and $res;
421 print "#'$@','$res','$blah'\nnot " unless $@ and $@ =~ /not allowed at runtime/ and $blah == 12;
427 $code = '{$blah = 45}';
430 print "not " if $blah != 45;
436 print "not " if $blah != 45;
442 print "not " unless pos($x) == 2;
447 print "not " unless pos($x) == 2;
457 print "not " unless f(pos($x)) == 4;
462 'foot' =~ /foo(?{$x = 12; 75})[t]/;
463 print "not " unless $^R eq '75';
468 'foot' =~ /foo(?{$x = 12; 75})[xy]/;
469 print "not " unless $^R eq '67' and $x eq '12';
474 'foot' =~ /foo(?{ $^R + 12 })((?{ $x = 12; $^R + 17 })[xy])?/;
475 print "not " unless $^R eq '79' and $x eq '12';
479 print "not " unless qr/\b\v$/i eq '(?i-xsm:\bv$)';
483 print "not " unless qr/\b\v$/s eq '(?s-xim:\bv$)';
487 print "not " unless qr/\b\v$/m eq '(?m-xis:\bv$)';
491 print "not " unless qr/\b\v$/x eq '(?x-ism:\bv$)';
495 print "not " unless qr/\b\v$/xism eq '(?msix:\bv$)';
499 print "not " unless qr/\b\v$/ eq '(?-xism:\bv$)';
504 foreach $ans ('', 'c') {
505 /(?<=(?=a)..)((?=c)|.)/g;
506 print "# \$1 ='$1'\n# \$ans='$ans'\nnot " unless $1 eq $ans;
512 foreach $ans ('', 'a', '') {
514 print "# \$& ='$&'\n# \$ans='$ans'\nnot " unless $& eq $ans;
520 my($v,$a,$b,$res) = @_;
522 print "not " unless $res eq $v;
526 prefixify('/a/b/lib/arch', "/a/b/lib", 'X/lib', 'X/lib/arch');
527 prefixify('/a/b/man/arch', "/a/b/man", 'X/man', 'X/man/arch');
531 print "not " unless $1 and /$1/;
538 print "not " unless $b eq '9';
544 print "not " unless $b eq '11';
551 print "not " unless $b eq '14';
559 my $lex_res = ($lex_b =~ qr/$lex_b(?{ $lex_c = $lex_a++ })/);
560 print "not " unless $lex_res eq '1';
563 print "not " unless $lex_a eq '44';
566 print "not " unless $lex_c eq '43';
572 $match = eval { /$a$c$a/ };
574 unless $b eq '14' and $@ =~ /Eval-group not allowed/ and not $match;
584 my $lex_res = ($lex_b =~ qr/17(?{ $lex_c = $lex_a++ })/);
585 print "not " unless $lex_res eq '1';
588 print "not " unless $lex_a eq '44';
591 print "not " unless $lex_c eq '43';
600 '' =~ /(?{ $c = 4 })/;
601 print "not " unless $c == 4;
605 print "not " unless $c == 3;
610 my $warn_pat = shift;
611 return sub { print "not " unless $_[0] =~ /$warn_pat/ }
615 my ($warn_pat, $code) = @_;
617 eval 'BEGIN { use warnings; $SIG{__WARN__} = $warn_pat };' . $code;
624 my $warn_pat = shift;
625 return sub { must_warn(must_warn_pat($warn_pat)) }
628 my $for_future = make_must_warn('reserved for future extensions');
630 &$for_future('q(a:[b]:) =~ /[x[:foo:]]/');
632 #&$for_future('q(a=[b]=) =~ /[x[=foo=]]/');
633 print "ok $test\n"; $test++; # now a fatal croak
635 #&$for_future('q(a.[b].) =~ /[x[.foo.]]/');
636 print "ok $test\n"; $test++; # now a fatal croak
638 # test if failure of patterns returns empty list
661 print "not " if $#+ != 0 or $#- != 0;
665 print "not " if $+[0] != 2 or $-[0] != 1;
670 if defined $+[1] or defined $-[1] or defined $+[2] or defined $-[2];
675 print "not " if $#+ != 2 or $#- != 2;
679 print "not " if $+[0] != 3 or $-[0] != 0;
683 print "not " if $+[1] != 2 or $-[1] != 1;
687 print "not " if $+[2] != 3 or $-[2] != 2;
692 if defined $+[3] or defined $-[3] or defined $+[4] or defined $-[4];
697 print "not " if $#+ != 3 or $#- != 3;
701 print "not " if $+[0] != 3 or $-[0] != 0;
705 print "not " if $+[1] != 2 or $-[1] != 1;
709 print "not " if $+[3] != 3 or $-[3] != 2;
714 if defined $+[2] or defined $-[2] or defined $+[4] or defined $-[4];
719 print "not " if $#+ != 1 or $#- != 1;
723 print "not " if $+[0] != 2 or $-[0] != 0;
727 print "not " if $+[1] != 2 or $-[1] != 1;
732 if defined $+[2] or defined $-[2] or defined $+[3] or defined $-[3];
736 eval { $+[0] = 13; };
738 if $@ !~ /^Modification of a read-only value attempted/;
742 eval { $-[0] = 13; };
744 if $@ !~ /^Modification of a read-only value attempted/;
748 eval { @+ = (7, 6, 5); };
750 if $@ !~ /^Modification of a read-only value attempted/;
754 eval { @- = qw(foo bar); };
756 if $@ !~ /^Modification of a read-only value attempted/;
761 print "#$#-..$#+\nnot " if $#+ != 2 or $#- != 1;
768 print "not " unless "@a" eq "a a";
775 print "not " if $str =~ /^\G/;
779 print "not " if $str =~ /^.\G/;
783 print "not " unless $str =~ /^..\G/;
787 print "not " if $str =~ /^...\G/;
791 print "not " unless $str =~ /.\G./ and $& eq 'bc';
795 print "not " unless $str =~ /\G../ and $& eq 'cd';
799 undef $foo; undef $bar;
800 print "#'$str','$foo','$bar'\nnot "
801 unless $str =~ /b(?{$foo = $_; $bar = pos})c/
802 and $foo eq 'abcde' and $bar eq 2;
806 undef $foo; undef $bar;
808 print "#'$str','$foo','$bar'\nnot "
809 unless $str =~ /b(?{$foo = $_; $bar = pos})c/g
810 and $foo eq 'abcde' and $bar eq 2 and pos $str eq 3;
816 undef $foo; undef $bar;
817 print "#'$str','$foo','$bar'\nnot "
818 unless /b(?{$foo = $_; $bar = pos})c/
819 and $foo eq 'abcde' and $bar eq 2;
823 undef $foo; undef $bar;
824 print "#'$str','$foo','$bar'\nnot "
825 unless /b(?{$foo = $_; $bar = pos})c/g
826 and $foo eq 'abcde' and $bar eq 2 and pos eq 3;
830 undef $foo; undef $bar;
832 1 while /b(?{$foo = $_; $bar = pos})c/g;
833 print "#'$str','$foo','$bar'\nnot "
834 unless $foo eq 'abcde' and $bar eq 2 and not defined pos;
838 undef $foo; undef $bar;
840 print "#'$str','$foo','$bar','$_'\nnot "
841 unless s/b(?{$foo = $_; $bar = pos})c/x/g and $foo eq 'abcde|abcde'
842 and $bar eq 8 and $_ eq 'axde|axde';
849 @dummy = /([ace]).(?{push @res, $1,$2})([ce])(?{push @res, $1,$2})/g;
850 @res = map {defined $_ ? "'$_'" : 'undef'} @res;
852 print "#'@res' '$_'\nnot "
853 unless "@res" eq "'a' undef 'a' 'c' 'e' undef 'a' undef 'a' 'c'";
858 @dummy = /([ace]).(?{push @res, $`,$&,$'})([ce])(?{push @res, $`,$&,$'})/g;
859 @res = map {defined $_ ? "'$_'" : 'undef'} @res;
861 print "#'@res' '$_'\nnot "
863 "'' 'ab' 'cde|abcde' " .
864 "'' 'abc' 'de|abcde' " .
865 "'abcd' 'e|' 'abcde' " .
866 "'abcde|' 'ab' 'cde' " .
867 "'abcde|' 'abc' 'de'" ;
871 #Some more \G anchor checks
872 $foo='aabbccddeeffgg';
877 print "not " unless($1 eq 'ab');
883 print "not " unless($1 eq 'cc');
889 print "not " unless($1 eq 'de');
893 print "not " unless $foo =~ /\Gef/g;
900 print "not " unless($1 eq 'aa');
905 print "not " unless($1 eq 'bb');
911 print "not " unless($1 eq 'cd');
917 print "not " unless('123||x|123|' eq join '|', @res);
921 # see if matching against temporaries (created via pp_helem()) is safe
922 { foo => "ok $test\n".$^X }->{foo} =~ /^(.*)\n/g;
926 # See if $i work inside (?{}) in the presense of saved substrings and
930 s/(\w)(?{push @b, $1})/,$1,/g for @a;
932 print "# \@b='@b', expect 'f o o b a r'\nnot " unless("@b" eq "f o o b a r");
936 print "not " unless("@a" eq ",f,,o,,o, ,b,,a,,r,");
941 { (?> [^{}]+ | (??{ $brackets }) )* }
945 print "ok $test\n"; # Did we survive?
948 "something { long { and } hairy" =~ $brackets;
949 print "ok $test\n"; # Did we survive?
952 "something { long { and } hairy" =~ m/((??{ $brackets }))/;
953 print "not " unless $1 eq "{ and }";
959 m/^-.*bb/mg and print "not ";
965 $text =~ /\GXb*X/g and print 'not ';
969 $text = "xA\n" x 500;
970 $text =~ /^\s*A/m and print 'not ';
975 @res = ($text =~ /.*?(b).*?\b/g);
976 "@res" eq 'b b' or print 'not ';
983 @c = grep(/[^\s]/,@a);
984 print "not " if "@b" ne "@c";
989 @c = grep(/[\S]/,@a);
990 print "not " if "@b" ne "@c";
995 @c = grep(/[^\S]/,@a);
996 print "not " if "@b" ne "@c";
1001 @c = grep(/[\s]/,@a);
1002 print "not " if "@b" ne "@c";
1007 @c = grep(/[^\d]/,@a);
1008 print "not " if "@b" ne "@c";
1013 @c = grep(/[\D]/,@a);
1014 print "not " if "@b" ne "@c";
1019 @c = grep(/[^\D]/,@a);
1020 print "not " if "@b" ne "@c";
1025 @c = grep(/[\d]/,@a);
1026 print "not " if "@b" ne "@c";
1031 @c = grep(/[^\w]/,@a);
1032 print "not " if "@b" ne "@c";
1037 @c = grep(/[\W]/,@a);
1038 print "not " if "@b" ne "@c";
1043 @c = grep(/[^\W]/,@a);
1044 print "not " if "@b" ne "@c";
1049 @c = grep(/[\w]/,@a);
1050 print "not " if "@b" ne "@c";
1054 # see if backtracking optimization works correctly
1055 "\n\n" =~ /\n $ \n/x or print "not ";
1059 "\n\n" =~ /\n* $ \n/x or print "not ";
1063 "\n\n" =~ /\n+ $ \n/x or print "not ";
1067 [] =~ /^ARRAY/ or print "# [] \nnot ";
1074 use overload '""' => sub { 'Object S' };
1075 sub new { bless [] }
1080 $a and $a =~ /^Object\sS/ or print "# '$a' \nnot ";
1084 # test result of match used as match (!)
1085 'a1b' =~ ('xyz' =~ /y/) and $` eq 'a' or print "not ";
1089 'a1b' =~ ('xyz' =~ /t/) and $` eq 'a' or print "not ";
1095 local $SIG{__WARN__} = sub { $w = 1 };
1097 $w = 1 if ("1\n" x 102) =~ /^\s*\n/m;
1099 print $w ? "not " : "", "ok $test\n";
1102 my %space = ( spc => " ",
1107 # There's no \v but the vertical tabulator seems miraculously
1108 # be 11 both in ASCII and EBCDIC.
1112 my @space0 = sort grep { $space{$_} =~ /\s/ } keys %space;
1113 my @space1 = sort grep { $space{$_} =~ /[[:space:]]/ } keys %space;
1114 my @space2 = sort grep { $space{$_} =~ /[[:blank:]]/ } keys %space;
1116 print "not " unless "@space0" eq "cr ff lf spc tab";
1117 print "ok $test # @space0\n";
1120 print "not " unless "@space1" eq "cr ff lf spc tab vt";
1121 print "ok $test # @space1\n";
1124 print "not " unless "@space2" eq "spc tab";
1125 print "ok $test # @space2\n";
1128 # bugid 20001021.005 - this caused a SEGV
1129 print "not " unless undef =~ /^([^\/]*)(.*)$/;
1133 # bugid 20000731.001
1135 print "not " unless "A \x{263a} B z C" =~ /A . B (??{ "z" }) C/;
1139 my $ordA = ord('A');
1142 if (/(.)(\C)(\C)(.)/) {
1147 print "not ok 233\n";
1149 if ($ordA == 65) { # ASCII (or equivalent), should be UTF-8
1153 print "not ok 234\n";
1158 print "not ok 235\n";
1160 } elsif ($ordA == 193) { # EBCDIC (or equivalent), should be UTF-EBCDIC
1164 print "not ok 234\n";
1169 print "not ok 235\n";
1173 print "not ok $_ # ord('A') == $ordA\n";
1179 print "not ok 236\n";
1183 print "not ok $_\n";
1189 # currently \C are still tagged as UTF-8
1194 print "not ok 238\n";
1196 } elsif ($ordA == 193) {
1200 print "not ok 238\n";
1203 print "not ok 238 # ord('A') == $ordA\n";
1207 print "not ok $_\n";
1212 # currently \C are still tagged as UTF-8
1217 print "not ok 240\n";
1219 } elsif ($ordA == 193) {
1223 print "not ok 240\n";
1226 print "not ok 240 # ord('A') == $ordA\n";
1230 print "not ok $_\n";
1235 # japhy -- added 03/03/2001
1236 () = (my $str = "abc") =~ /(...)/;
1238 print "not " if $1 ne "abc";
1242 # The 242 and 243 go with the 244 and 245.
1243 # The trick is that in EBCDIC the explicit numeric range should match
1244 # (as also in non-EBCDIC) but the explicit alphabetic range should not match.
1246 if ("\x8e" =~ /[\x89-\x91]/) {
1249 print "not ok 242\n";
1252 if ("\xce" =~ /[\xc9-\xd1]/) {
1255 print "not ok 243\n";
1258 # In most places these tests would succeed since \x8e does not
1259 # in most character sets match 'i' or 'j' nor would \xce match
1260 # 'I' or 'J', but strictly speaking these tests are here for
1261 # the good of EBCDIC, so let's test these only there.
1262 if (ord('i') == 0x89 && ord('J') == 0xd1) { # EBCDIC
1263 if ("\x8e" !~ /[i-j]/) {
1266 print "not ok 244\n";
1268 if ("\xce" !~ /[I-J]/) {
1271 print "not ok 245\n";
1275 print "ok $_ # Skip: only in EBCDIC\n";
1279 print "not " unless "\x{ab}" =~ /\x{ab}/;
1282 print "not " unless "\x{abcd}" =~ /\x{abcd}/;
1286 # bug id 20001008.001
1289 my @x = ("stra\337e 138","stra\337e 138");
1291 s/(\d+)\s*([\w\-]+)/$1 . uc $2/e;
1292 my($latin) = /^(.+)(?:\s+\d)/;
1293 print $latin eq "stra\337e" ? "ok $test\n" : # 248,249
1294 "#latin[$latin]\nnot ok $test\n";
1296 $latin =~ s/stra\337e/straße/; # \303\237 after the 2nd a
1297 use utf8; # needed for the raw UTF-8
1298 $latin =~ s!(s)tr(?:aß|s+e)!$1tr.!; # \303\237 after the a
1303 print "not " unless "ba\xd4c" =~ /([a\xd4]+)/ && $1 eq "a\xd4";
1306 print "not " unless "ba\xd4c" =~ /([a\xd4]+)/ && $1 eq "a\x{d4}";
1309 print "not " unless "ba\x{d4}c" =~ /([a\xd4]+)/ && $1 eq "a\x{d4}";
1312 print "not " unless "ba\x{d4}c" =~ /([a\xd4]+)/ && $1 eq "a\xd4";
1315 print "not " unless "ba\xd4c" =~ /([a\x{d4}]+)/ && $1 eq "a\xd4";
1318 print "not " unless "ba\xd4c" =~ /([a\x{d4}]+)/ && $1 eq "a\x{d4}";
1321 print "not " unless "ba\x{d4}c" =~ /([a\x{d4}]+)/ && $1 eq "a\x{d4}";
1324 print "not " unless "ba\x{d4}c" =~ /([a\x{d4}]+)/ && $1 eq "a\xd4";
1329 # the first half of 20001028.003
1332 my ($Y) = $X =~ /(.*)/;
1333 print "not " unless $Y eq v1448 && length($Y) == 1;
1340 my $X = "Szab\x{f3},Bal\x{e1}zs";
1342 $Y =~ s/(B)/$1/ for 0..3;
1343 print "not " unless $Y eq $X && $X eq "Szab\x{f3},Bal\x{e1}zs";
1348 # the second half of 20001028.003
1351 $X =~ s/^/chr(1488)/e;
1352 print "not " unless length $X == 1 && ord($X) == 1488;
1363 print "not " unless $x eq "\x{100}B" && length($x) == 2;
1368 # bug id 20001230.002
1370 print "not " unless "École" =~ /^\C\C(.)/ && $1 eq 'c';
1373 print "not " unless "École" =~ /^\C\C(c)/;
1378 my $test = 264; # till 575
1380 use charnames ":full";
1382 # This is far from complete testing, there are dozens of character
1383 # classes in Unicode. The mixing of literals and \N{...} is
1384 # intentional so that in non-Latin-1 places we test the native
1385 # characters, not the Unicode code points.
1389 "\N{CYRILLIC SMALL LETTER A}" => 'Ll',
1391 "\N{GREEK CAPITAL LETTER ALPHA}" => 'Lu',
1392 "\N{HIRAGANA LETTER SMALL A}" => 'Lo',
1393 "\N{COMBINING GRAVE ACCENT}" => 'Mn',
1395 "\N{ARABIC-INDIC DIGIT ZERO}" => 'Nd',
1402 for my $char (map { s/^\S+ //; $_ }
1403 sort map { sprintf("%06x", ord($_))." $_" } keys %s) {
1404 my $class = $s{$char};
1405 my $code = sprintf("%06x", ord($char));
1406 printf "#\n# 0x$code\n#\n";
1407 print "# IsAlpha\n";
1408 if ($class =~ /^[LM]/) {
1409 print "not " unless $char =~ /\p{IsAlpha}/;
1410 print "ok $test\n"; $test++;
1411 print "not " if $char =~ /\P{IsAlpha}/;
1412 print "ok $test\n"; $test++;
1414 print "not " if $char =~ /\p{IsAlpha}/;
1415 print "ok $test\n"; $test++;
1416 print "not " unless $char =~ /\P{IsAlpha}/;
1417 print "ok $test\n"; $test++;
1419 print "# IsAlnum\n";
1420 if ($class =~ /^[LMN]/ && $char ne "_") {
1421 print "not " unless $char =~ /\p{IsAlnum}/;
1422 print "ok $test\n"; $test++;
1423 print "not " if $char =~ /\P{IsAlnum}/;
1424 print "ok $test\n"; $test++;
1426 print "not " if $char =~ /\p{IsAlnum}/;
1427 print "ok $test\n"; $test++;
1428 print "not " unless $char =~ /\P{IsAlnum}/;
1429 print "ok $test\n"; $test++;
1431 print "# IsASCII\n";
1432 if (ord("A") == 193) {
1433 print "ok $test # Skip: in EBCDIC\n"; $test++;
1434 print "ok $test # Skip: in EBCDIC\n"; $test++;
1436 if ($code le '00007f') {
1437 print "not " unless $char =~ /\p{IsASCII}/;
1438 print "ok $test\n"; $test++;
1439 print "not " if $char =~ /\P{IsASCII}/;
1440 print "ok $test\n"; $test++;
1442 print "not " if $char =~ /\p{IsASCII}/;
1443 print "ok $test\n"; $test++;
1444 print "not " unless $char =~ /\P{IsASCII}/;
1445 print "ok $test\n"; $test++;
1448 print "# IsCntrl\n";
1449 if ($class =~ /^C/) {
1450 print "not " unless $char =~ /\p{IsCntrl}/;
1451 print "ok $test\n"; $test++;
1452 print "not " if $char =~ /\P{IsCntrl}/;
1453 print "ok $test\n"; $test++;
1455 print "not " if $char =~ /\p{IsCntrl}/;
1456 print "ok $test\n"; $test++;
1457 print "not " unless $char =~ /\P{IsCntrl}/;
1458 print "ok $test\n"; $test++;
1460 print "# IsBlank\n";
1461 if ($class =~ /^Z[lp]/ || $char eq " ") {
1462 print "not " unless $char =~ /\p{IsBlank}/;
1463 print "ok $test\n"; $test++;
1464 print "not " if $char =~ /\P{IsBlank}/;
1465 print "ok $test\n"; $test++;
1467 print "not " if $char =~ /\p{IsBlank}/;
1468 print "ok $test\n"; $test++;
1469 print "not " unless $char =~ /\P{IsBlank}/;
1470 print "ok $test\n"; $test++;
1472 print "# IsDigit\n";
1473 if ($class =~ /^Nd$/) {
1474 print "not " unless $char =~ /\p{IsDigit}/;
1475 print "ok $test\n"; $test++;
1476 print "not " if $char =~ /\P{IsDigit}/;
1477 print "ok $test\n"; $test++;
1479 print "not " if $char =~ /\p{IsDigit}/;
1480 print "ok $test\n"; $test++;
1481 print "not " unless $char =~ /\P{IsDigit}/;
1482 print "ok $test\n"; $test++;
1484 print "# IsGraph\n";
1485 if ($class =~ /^([LMNPS])|Co/) {
1486 print "not " unless $char =~ /\p{IsGraph}/;
1487 print "ok $test\n"; $test++;
1488 print "not " if $char =~ /\P{IsGraph}/;
1489 print "ok $test\n"; $test++;
1491 print "not " if $char =~ /\p{IsGraph}/;
1492 print "ok $test\n"; $test++;
1493 print "not " unless $char =~ /\P{IsGraph}/;
1494 print "ok $test\n"; $test++;
1496 print "# IsLower\n";
1497 if ($class =~ /^Ll$/) {
1498 print "not " unless $char =~ /\p{IsLower}/;
1499 print "ok $test\n"; $test++;
1500 print "not " if $char =~ /\P{IsLower}/;
1501 print "ok $test\n"; $test++;
1503 print "not " if $char =~ /\p{IsLower}/;
1504 print "ok $test\n"; $test++;
1505 print "not " unless $char =~ /\P{IsLower}/;
1506 print "ok $test\n"; $test++;
1508 print "# IsPrint\n";
1509 if ($class =~ /^([LMNPS])|Co|Zs/) {
1510 print "not " unless $char =~ /\p{IsPrint}/;
1511 print "ok $test\n"; $test++;
1512 print "not " if $char =~ /\P{IsPrint}/;
1513 print "ok $test\n"; $test++;
1515 print "not " if $char =~ /\p{IsPrint}/;
1516 print "ok $test\n"; $test++;
1517 print "not " unless $char =~ /\P{IsPrint}/;
1518 print "ok $test\n"; $test++;
1520 print "# IsPunct\n";
1521 if ($class =~ /^P/ || $char eq "_") {
1522 print "not " unless $char =~ /\p{IsPunct}/;
1523 print "ok $test\n"; $test++;
1524 print "not " if $char =~ /\P{IsPunct}/;
1525 print "ok $test\n"; $test++;
1527 print "not " if $char =~ /\p{IsPunct}/;
1528 print "ok $test\n"; $test++;
1529 print "not " unless $char =~ /\P{IsPunct}/;
1530 print "ok $test\n"; $test++;
1532 print "# IsSpace\n";
1533 if ($class =~ /^Z/ || ($code =~ /^(0009|000A|000B|000C|000D)$/)) {
1534 print "not " unless $char =~ /\p{IsSpace}/;
1535 print "ok $test\n"; $test++;
1536 print "not " if $char =~ /\P{IsSpace}/;
1537 print "ok $test\n"; $test++;
1539 print "not " if $char =~ /\p{IsSpace}/;
1540 print "ok $test\n"; $test++;
1541 print "not " unless $char =~ /\P{IsSpace}/;
1542 print "ok $test\n"; $test++;
1544 print "# IsUpper\n";
1545 if ($class =~ /^L[ut]/) {
1546 print "not " unless $char =~ /\p{IsUpper}/;
1547 print "ok $test\n"; $test++;
1548 print "not " if $char =~ /\P{IsUpper}/;
1549 print "ok $test\n"; $test++;
1551 print "not " if $char =~ /\p{IsUpper}/;
1552 print "ok $test\n"; $test++;
1553 print "not " unless $char =~ /\P{IsUpper}/;
1554 print "ok $test\n"; $test++;
1557 if ($class =~ /^[LMN]/ || $char eq "_") {
1558 print "not " unless $char =~ /\p{IsWord}/;
1559 print "ok $test\n"; $test++;
1560 print "not " if $char =~ /\P{IsWord}/;
1561 print "ok $test\n"; $test++;
1563 print "not " if $char =~ /\p{IsWord}/;
1564 print "ok $test\n"; $test++;
1565 print "not " unless $char =~ /\P{IsWord}/;
1566 print "ok $test\n"; $test++;
1572 $_ = "abc\x{100}\x{200}\x{300}\x{380}\x{400}defg";
1574 if (/(.\x{300})./) {
1577 print "not " unless $` eq "abc\x{100}" && length($`) == 4;
1580 print "not " unless $& eq "\x{200}\x{300}\x{380}" && length($&) == 3;
1583 print "not " unless $' eq "\x{400}defg" && length($') == 5;
1586 print "not " unless $1 eq "\x{200}\x{300}" && length($1) == 2;
1589 for (576..580) { print "not ok $_\n" }
1594 # bug id 20010306.008
1597 # The original bug report had 'no utf8' here but that was irrelevant.
1598 $a =~ m/\w/; # used to core dump
1606 # bugid 20010410.006
1608 '/(.*?)\{(.*?)\}/csg',
1609 '/(.*?)\{(.*?)\}/cg',
1610 '/(.*?)\{(.*?)\}/sg',
1611 '/(.*?)\{(.*?)\}/g',
1612 '/(.+?)\{(.+?)\}/csg',
1618 $input = "a{b}c{d}";
1620 while (eval \$input =~ $rx) {
1621 print "# \\\$1 = '\$1' \\\$2 = '\$2'\n";
1625 print "not " unless $i == 2;
1626 print "ok " . $test++ . "\n";
1631 # from Robin Houston
1633 my $x = "\x{10FFFD}";
1635 print "not " unless ord($x) == 0x10FFFD && length($x) == 1;
1642 print "not " if $x =~ /[\x80-\xff]/;
1645 print "not " if $x =~ /[\x80-\x{100}]/;
1648 print "not " if $x =~ /[\x{100}]/;
1651 print "not " if $x =~ /\p{InLatin1Supplement}/;
1654 print "not " unless $x =~ /\P{InLatin1Supplement}/;
1657 print "not " if $x =~ /\p{InLatinExtendedA}/;
1660 print "not " unless $x =~ /\P{InLatinExtendedA}/;
1667 print "not " unless $x =~ /[\x80-\xff]/;
1670 print "not " unless $x =~ /[\x80-\x{100}]/;
1673 print "not " if $x =~ /[\x{100}]/;
1676 print "not " unless $x =~ /\p{InLatin1Supplement}/;
1679 print "not " if $x =~ /\P{InLatin1Supplement}/;
1682 print "not " if $x =~ /\p{InLatinExtendedA}/;
1685 print "not " unless $x =~ /\P{InLatinExtendedA}/;
1692 print "not " unless $x =~ /[\x80-\xff]/;
1695 print "not " unless $x =~ /[\x80-\x{100}]/;
1698 print "not " if $x =~ /[\x{100}]/;
1701 # the next two tests must be ignored on EBCDIC
1702 print "not " unless $x =~ /\p{InLatin1Supplement}/ or ord("A") == 193;
1705 print "not " if $x =~ /\P{InLatin1Supplement}/ and ord("A") != 193;
1708 print "not " if $x =~ /\p{InLatinExtendedA}/;
1711 print "not " unless $x =~ /\P{InLatinExtendedA}/;
1718 print "not " if $x =~ /[\x80-\xff]/;
1721 print "not " unless $x =~ /[\x80-\x{100}]/;
1724 print "not " unless $x =~ /[\x{100}]/;
1727 print "not " if $x =~ /\p{InLatin1Supplement}/;
1730 print "not " unless $x =~ /\P{InLatin1Supplement}/;
1733 print "not " unless $x =~ /\p{InLatinExtendedA}/;
1736 print "not " if $x =~ /\P{InLatinExtendedA}/;
1744 local $SIG{__WARN__} = sub { $w .= shift };
1748 print "not " if $w !~ /^Useless \(\?c\)/;
1753 print "not " if $w !~ /^Useless \(\?-c\)/;
1758 print "not " if $w !~ /^Useless \(\?g\)/;
1763 print "not " if $w !~ /^Useless \(\?-g\)/;
1768 print "not " if $w !~ /^Useless \(\?o\)/;
1773 print "not " if $w !~ /^Useless \(\?-o\)/;
1776 # now test multi-error regexes
1780 print "not " if $w !~ /^Useless \(\?g\).*\nUseless \(\?-o\)/;
1785 print "not " if $w !~ /^Useless \(\?g\).*\nUseless \(\?-c\)/;
1789 eval 'qr/(?o-cg)/'; # (?c) means (?g) error won't be thrown
1790 print "not " if $w !~ /^Useless \(\?o\).*\nUseless \(\?-c\)/;
1795 print "not " if $w !~ /^Useless \(\?o\).*\nUseless \(\?g\).*\nUseless \(\?c\)/;
1799 # More Unicode "class" tests
1802 use charnames ':full';
1804 print "not " unless "\N{LATIN CAPITAL LETTER A}" =~ /\p{InBasicLatin}/;
1807 print "not " unless "\N{LATIN CAPITAL LETTER A WITH GRAVE}" =~ /\p{InLatin1Supplement}/;
1810 print "not " unless "\N{LATIN CAPITAL LETTER A WITH MACRON}" =~ /\p{InLatinExtendedA}/;
1813 print "not " unless "\N{LATIN SMALL LETTER B WITH STROKE}" =~ /\p{InLatinExtendedB}/;
1816 print "not " unless "\N{KATAKANA LETTER SMALL A}" =~ /\p{InKatakana}/;
1822 eval <<"EOT"; die if $@;
1827 /x && print "ok 631\n";
1830 eval <<"EOT"; die if $@;
1835 /x && print "ok 632\n";
1839 sub test_o { $_[0] =~/$_[1]/o; return $1}
1840 if(test_o('abc','(.)..') eq 'a') {
1843 print "not ok 633\n";
1845 if(test_o('abc','..(.)') eq 'a') {
1848 print "not ok 634\n";
1851 # 635..639: ID 20010619.003 (only the space character is
1852 # supposed to be [:print:], not the whole isprint()).
1854 print "not " if "\n" =~ /[[:print:]]/;
1857 print "not " if "\t" =~ /[[:print:]]/;
1860 # Amazingly vertical tabulator is the same in ASCII and EBCDIC.
1861 print "not " if "\014" =~ /[[:print:]]/;
1864 print "not " if "\r" =~ /[[:print:]]/;
1867 print "not " unless " " =~ /[[:print:]]/;
1871 ## Test basic $^N usage outside of a regex
1874 $T="ok 640\n";if ($x =~ /cde/ and not defined $^N) {print $T} else {print "not $T"};
1875 $T="ok 641\n";if ($x =~ /(cde)/ and $^N eq "cde") {print $T} else {print "not $T"};
1876 $T="ok 642\n";if ($x =~ /(c)(d)(e)/ and $^N eq "e") {print $T} else {print "not $T"};
1877 $T="ok 643\n";if ($x =~ /(c(d)e)/ and $^N eq "cde") {print $T} else {print "not $T"};
1878 $T="ok 644\n";if ($x =~ /(foo)|(c(d)e)/ and $^N eq "cde") {print $T} else {print "not $T"};
1879 $T="ok 645\n";if ($x =~ /(c(d)e)|(foo)/ and $^N eq "cde") {print $T} else {print "not $T"};
1880 $T="ok 646\n";if ($x =~ /(c(d)e)|(abc)/ and $^N eq "abc") {print $T} else {print "not $T"};
1881 $T="ok 647\n";if ($x =~ /(c(d)e)|(abc)x/ and $^N eq "cde") {print $T} else {print "not $T"};
1882 $T="ok 648\n";if ($x =~ /(c(d)e)(abc)?/ and $^N eq "cde") {print $T} else {print "not $T"};
1883 $T="ok 649\n";if ($x =~ /(?:c(d)e)/ and $^N eq "d" ) {print $T} else {print "not $T"};
1884 $T="ok 650\n";if ($x =~ /(?:c(d)e)(?:f)/ and $^N eq "d" ) {print $T} else {print "not $T"};
1885 $T="ok 651\n";if ($x =~ /(?:([abc])|([def]))*/ and $^N eq "f" ){print $T} else {print "not $T"};
1886 $T="ok 652\n";if ($x =~ /(?:([ace])|([bdf]))*/ and $^N eq "f" ){print $T} else {print "not $T"};
1887 $T="ok 653\n";if ($x =~ /(([ace])|([bd]))*/ and $^N eq "e" ){print $T} else {print "not $T"};
1889 $T="ok 654\n";if($x =~ /(([ace])|([bdf]))*/ and $^N eq "f" ){print $T} else {print "not $T"};
1891 ## test to see if $^N is automatically localized -- it should now
1892 ## have the value set in test 653
1893 $T="ok 655\n";if ($^N eq "e" ){print $T} else {print "not $T"};
1896 ## Now test inside (?{...})
1898 $T="ok 656\n";if ($x =~ /a([abc])(?{$y=$^N})c/ and $y eq "b" ){print $T} else {print "not $T"};
1899 $T="ok 657\n";if ($x =~ /a([abc]+)(?{$y=$^N})d/ and $y eq "bc"){print $T} else {print "not $T"};
1900 $T="ok 658\n";if ($x =~ /a([abcdefg]+)(?{$y=$^N})d/ and $y eq "bc"){print $T} else {print "not $T"};
1901 $T="ok 659\n";if ($x =~ /(a([abcdefg]+)(?{$y=$^N})d)(?{$z=$^N})e/ and $y eq "bc" and $z eq "abcd")
1902 {print $T} else {print "not $T"};
1903 $T="ok 660\n";if ($x =~ /(a([abcdefg]+)(?{$y=$^N})de)(?{$z=$^N})/ and $y eq "bc" and $z eq "abcde")
1904 {print $T} else {print "not $T"};
1906 # Test the Unicode script classes
1908 print "not " unless chr(0x100) =~ /\p{IsLatin}/; # outside Latin-1
1911 print "not " unless chr(0x212b) =~ /\p{IsLatin}/; # Angstrom sign, very outside
1914 print "not " unless chr(0x5d0) =~ /\p{IsHebrew}/; # inside InHebrew
1917 print "not " unless chr(0xfb4f) =~ /\p{IsHebrew}/; # outside InHebrew
1920 # # singleton (not in a range, this test must be ignored on EBCDIC)
1921 # print "not " unless chr(0xb5) =~ /\p{IsGreek}/ or ord("A") == 193;
1923 print "ok 665 # 0xb5 moved from Greek to Common with Unicode 4.0.1\n";
1925 print "not " unless chr(0x37a) =~ /\p{IsGreek}/; # singleton
1928 print "not " unless chr(0x386) =~ /\p{IsGreek}/; # singleton
1931 print "not " unless chr(0x387) =~ /\P{IsGreek}/; # not there
1934 print "not " unless chr(0x388) =~ /\p{IsGreek}/; # range
1937 print "not " unless chr(0x38a) =~ /\p{IsGreek}/; # range
1940 print "not " unless chr(0x38b) =~ /\P{IsGreek}/; # not there
1943 print "not " unless chr(0x38c) =~ /\p{IsGreek}/; # singleton
1946 if (ord("A") == 65) {
1948 ## Test [:cntrl:]...
1950 ## Should probably put in tests for all the POSIX stuff, but not sure how to
1951 ## guarantee a specific locale......
1953 $AllBytes = join('', map { chr($_) } 0..255);
1954 ($x = $AllBytes) =~ s/[[:cntrl:]]//g;
1955 if ($x ne join('', map { chr($_) } 0x20..0x7E, 0x80..0xFF)) {
1960 ($x = $AllBytes) =~ s/[^[:cntrl:]]//g;
1961 if ($x ne join('', map { chr($_) } 0..0x1F, 0x7F)) { print "not " }
1964 print "ok $_ # Skip: EBCDIC\n" for 673..674;
1967 # With /s modifier UTF8 chars were interpreted as bytes
1969 my $a = "Hello \x{263A} World";
1971 my @a = ($a =~ /./gs);
1973 print "not " unless $#a == 12;
1977 @a = ("foo\nbar" =~ /./g);
1978 print "ok 676\n" if @a == 6 && "@a" eq "f o o b a r";
1980 @a = ("foo\nbar" =~ /./gs);
1981 print "ok 677\n" if @a == 7 && "@a" eq "f o o \n b a r";
1983 @a = ("foo\nbar" =~ /\C/g);
1984 print "ok 678\n" if @a == 7 && "@a" eq "f o o \n b a r";
1986 @a = ("foo\nbar" =~ /\C/gs);
1987 print "ok 679\n" if @a == 7 && "@a" eq "f o o \n b a r";
1989 @a = ("foo\n\x{100}bar" =~ /./g);
1990 print "ok 680\n" if @a == 7 && "@a" eq "f o o \x{100} b a r";
1992 @a = ("foo\n\x{100}bar" =~ /./gs);
1993 print "ok 681\n" if @a == 8 && "@a" eq "f o o \n \x{100} b a r";
1995 ($a, $b) = map { chr } ord('A') == 65 ? (0xc4, 0x80) : (0x8c, 0x41);
1997 @a = ("foo\n\x{100}bar" =~ /\C/g);
1998 print "ok 682\n" if @a == 9 && "@a" eq "f o o \n $a $b b a r";
2000 @a = ("foo\n\x{100}bar" =~ /\C/gs);
2001 print "ok 683\n" if @a == 9 && "@a" eq "f o o \n $a $b b a r";
2004 # [ID 20010814.004] pos() doesn't work when using =~m// in list context
2006 $a = join ":", /b./gc;
2007 $b = join ":", /a./gc;
2009 print "$a $b $c" eq 'ba:ba ad:ae 10' ? "ok 684\n" : "not ok 684\t# $a $b $c\n";
2013 # [ID 20010407.006] matching utf8 return values from functions does not work
2015 package ID_20010407_006;
2024 $x =~ /(..)/; $y = $1;
2025 print "not " unless length($y) == 2 && $y eq $x;
2028 x =~ /(..)/; $y = $1;
2029 print "not " unless length($y) == 2 && $y eq $x;
2036 # Force scalar context on the patern match
2038 my($ok, $name) = @_;
2040 printf "%sok %d - %s\n", ($ok ? "" : "not "), $test, $name;
2042 printf "# Failed test at line %d\n", (caller)[2] unless $ok;
2049 # Check that \x## works. 5.6.1 and 5.005_03 fail some of these.
2051 ok ($x =~ /^\x4EE$/, "Check only 2 bytes of hex are matched.");
2054 ok ($x =~ /^\x4Ei$/, "Check that invalid hex digit stops it (2)");
2057 ok ($x =~ /^\x4j$/, "Check that invalid hex digit stops it (1)");
2060 ok ($x =~ /^\xk$/, "Check that invalid hex digit stops it (0)");
2063 ok ($x =~ /^\xx$/, "\\xx isn't to be treated as \\0");
2066 ok ($x =~ /^\xxa$/, "\\xxa isn't to be treated as \\xa");
2069 ok ($x =~ /^\x9_b$/, "\\x9_b isn't to be treated as \\x9b");
2071 print "# and now again in [] ranges\n";
2074 ok ($x =~ /^[\x4EE]{2}$/, "Check only 2 bytes of hex are matched.");
2077 ok ($x =~ /^[\x4Ei]{2}$/, "Check that invalid hex digit stops it (2)");
2080 ok ($x =~ /^[\x4j]{2}$/, "Check that invalid hex digit stops it (1)");
2083 ok ($x =~ /^[\xk]{2}$/, "Check that invalid hex digit stops it (0)");
2086 ok ($x =~ /^[\xx]{2}$/, "\\xx isn't to be treated as \\0");
2089 ok ($x =~ /^[\xxa]{3}$/, "\\xxa isn't to be treated as \\xa");
2092 ok ($x =~ /^[\x9_b]{3}$/, "\\x9_b isn't to be treated as \\x9b");
2097 # Check that \x{##} works. 5.6.1 fails quite a few of these.
2100 ok ($x =~ /^\x{9_b}$/, "\\x{9_b} is to be treated as \\x9b");
2103 ok ($x =~ /^\x{9_b}y$/, "\\x{9_b} is to be treated as \\x9b (again)");
2106 ok ($x =~ /^\x{9b_}y$/, "\\x{9b_} is to be treated as \\x9b");
2109 ok ($x =~ /^\x{9_bq}y$/, "\\x{9_bc} is to be treated as \\x9b");
2112 ok ($x =~ /^\x{x9b}y$/, "\\x{x9b} is to be treated as \\x0");
2115 ok ($x =~ /^\x{0x9b}y$/, "\\x{0x9b} is to be treated as \\x0");
2118 ok ($x =~ /^\x{09b}y$/, "\\x{09b} is to be treated as \\x9b");
2120 print "# and now again in [] ranges\n";
2123 ok ($x =~ /^[\x{9_b}]$/, "\\x{9_b} is to be treated as \\x9b");
2126 ok ($x =~ /^[\x{9_b}y]{2}$/, "\\x{9_b} is to be treated as \\x9b (again)");
2129 ok ($x =~ /^[\x{9b_}y]{2}$/, "\\x{9b_} is to be treated as \\x9b");
2132 ok ($x =~ /^[\x{9_bq}y]{2}$/, "\\x{9_bc} is to be treated as \\x9b");
2135 ok ($x =~ /^[\x{x9b}y]{2}$/, "\\x{x9b} is to be treated as \\x0");
2138 ok ($x =~ /^[\x{0x9b}y]{2}$/, "\\x{0x9b} is to be treated as \\x0");
2141 ok ($x =~ /^[\x{09b}y]{2}$/, "\\x{09b} is to be treated as \\x9b");
2145 # high bit bug -- japhy
2147 $x =~ /.*?\200/ or print "not ";
2151 print "# some Unicode properties\n";
2154 # Dashes, underbars, case.
2155 print "not " unless "\x80" =~ /\p{in-latin1_SUPPLEMENT}/;
2158 # Complement, leading and trailing whitespace.
2159 print "not " unless "\x80" =~ /\P{ ^ In Latin 1 Supplement }/;
2162 # No ^In, dashes, case, dash, any intervening (word-break) whitespace.
2163 # (well, newlines don't work...)
2164 print "not " unless "\x80" =~ /\p{latin-1 supplement}/;
2169 print "not " unless "a" =~ /\pL/;
2172 print "not " unless "a" =~ /\p{IsLl}/;
2175 print "not " if "a" =~ /\p{IsLu}/;
2178 print "not " unless "a" =~ /\p{Ll}/;
2181 print "not " if "a" =~ /\p{Lu}/;
2184 print "not " unless "A" =~ /\pL/;
2187 print "not " unless "A" =~ /\p{IsLu}/;
2190 print "not " if "A" =~ /\p{IsLl}/;
2193 print "not " unless "A" =~ /\p{Lu}/;
2196 print "not " if "A" =~ /\p{Ll}/;
2199 print "not " if "a" =~ /\PL/;
2202 print "not " if "a" =~ /\P{IsLl}/;
2205 print "not " unless "a" =~ /\P{IsLu}/;
2208 print "not " if "a" =~ /\P{Ll}/;
2211 print "not " unless "a" =~ /\P{Lu}/;
2214 print "not " if "A" =~ /\PL/;
2217 print "not " if "A" =~ /\P{IsLu}/;
2220 print "not " unless "A" =~ /\P{IsLl}/;
2223 print "not " if "A" =~ /\P{Lu}/;
2226 print "not " unless "A" =~ /\P{Ll}/;
2232 print "not " if "a" =~ /\p{Common}/;
2235 print "not " unless "1" =~ /\p{Common}/;
2240 print "not " if "a" =~ /\p{Inherited}/;
2243 print "not " unless "\x{300}" =~ /\p{Inherited}/;
2248 # L& and LC are the same
2249 print "not " unless "a" =~ /\p{LC}/ and "a" =~ /\p{L&}/;
2252 print "not " if "1" =~ /\p{LC}/ or "1" =~ /\p{L&}/;
2257 print "not " unless "a" =~ /\p{Lowercase Letter}/;
2260 print "not " if "A" =~ /\p{lowercaseletter}/;
2265 print "not " unless "\x{AC00}" =~ /\p{HangulSyllables}/;
2270 # Script=, Block=, Category=
2272 print "not " unless "\x{0100}" =~ /\p{Script=Latin}/;
2275 print "not " unless "\x{0100}" =~ /\p{Block=LatinExtendedA}/;
2278 print "not " unless "\x{0100}" =~ /\p{Category=UppercaseLetter}/;
2283 print "# the basic character classes and Unicode \n";
2285 # 0100;LATIN CAPITAL LETTER A WITH MACRON;Lu;0;L;0041 0304;;;;N;LATIN CAPITAL LETTER A MACRON;;;0101;
2286 print "not " unless "\x{0100}" =~ /\w/;
2289 # 0660;ARABIC-INDIC DIGIT ZERO;Nd;0;AN;;0;0;0;N;;;;;
2290 print "not " unless "\x{0660}" =~ /\d/;
2293 # 1680;OGHAM SPACE MARK;Zs;0;WS;;;;;N;;;;;
2294 print "not " unless "\x{1680}" =~ /\s/;
2299 print "# folding matches and Unicode\n";
2301 print "not " unless "a\x{100}" =~ /A/i;
2304 print "not " unless "A\x{100}" =~ /a/i;
2307 print "not " unless "a\x{100}" =~ /a/i;
2310 print "not " unless "A\x{100}" =~ /A/i;
2313 print "not " unless "\x{101}a" =~ /\x{100}/i;
2316 print "not " unless "\x{100}a" =~ /\x{100}/i;
2319 print "not " unless "\x{101}a" =~ /\x{101}/i;
2322 print "not " unless "\x{100}a" =~ /\x{101}/i;
2325 print "not " unless "a\x{100}" =~ /A\x{100}/i;
2328 print "not " unless "A\x{100}" =~ /a\x{100}/i;
2331 print "not " unless "a\x{100}" =~ /a\x{100}/i;
2334 print "not " unless "A\x{100}" =~ /A\x{100}/i;
2337 print "not " unless "a\x{100}" =~ /[A]/i;
2340 print "not " unless "A\x{100}" =~ /[a]/i;
2343 print "not " unless "a\x{100}" =~ /[a]/i;
2346 print "not " unless "A\x{100}" =~ /[A]/i;
2349 print "not " unless "\x{101}a" =~ /[\x{100}]/i;
2352 print "not " unless "\x{100}a" =~ /[\x{100}]/i;
2355 print "not " unless "\x{101}a" =~ /[\x{101}]/i;
2358 print "not " unless "\x{100}a" =~ /[\x{101}]/i;
2364 use charnames ':full';
2366 print "# LATIN LETTER A WITH GRAVE\n";
2367 my $lower = "\N{LATIN SMALL LETTER A WITH GRAVE}";
2368 my $UPPER = "\N{LATIN CAPITAL LETTER A WITH GRAVE}";
2370 print $lower =~ m/$UPPER/i ? "ok 774\n" : "not ok 774\n";
2371 print $UPPER =~ m/$lower/i ? "ok 775\n" : "not ok 775\n";
2372 print $lower =~ m/[$UPPER]/i ? "ok 776\n" : "not ok 776\n";
2373 print $UPPER =~ m/[$lower]/i ? "ok 777\n" : "not ok 777\n";
2375 print "# GREEK LETTER ALPHA WITH VRACHY\n";
2377 $lower = "\N{GREEK CAPITAL LETTER ALPHA WITH VRACHY}";
2378 $UPPER = "\N{GREEK SMALL LETTER ALPHA WITH VRACHY}";
2380 print $lower =~ m/$UPPER/i ? "ok 778\n" : "not ok 778\n";
2381 print $UPPER =~ m/$lower/i ? "ok 779\n" : "not ok 779\n";
2382 print $lower =~ m/[$UPPER]/i ? "ok 780\n" : "not ok 780\n";
2383 print $UPPER =~ m/[$lower]/i ? "ok 781\n" : "not ok 781\n";
2385 print "# LATIN LETTER Y WITH DIAERESIS\n";
2387 $lower = "\N{LATIN CAPITAL LETTER Y WITH DIAERESIS}";
2388 $UPPER = "\N{LATIN SMALL LETTER Y WITH DIAERESIS}";
2389 print $lower =~ m/$UPPER/i ? "ok 782\n" : "not ok 782\n";
2390 print $UPPER =~ m/$lower/i ? "ok 783\n" : "not ok 783\n";
2391 print $lower =~ m/[$UPPER]/i ? "ok 784\n" : "not ok 784\n";
2392 print $UPPER =~ m/[$lower]/i ? "ok 785\n" : "not ok 785\n";
2397 use charnames ':full';
2399 print "# GREEK CAPITAL LETTER SIGMA vs COMBINING GREEK PERISPOMENI\n";
2401 my $SIGMA = "\N{GREEK CAPITAL LETTER SIGMA}";
2402 my $char = "\N{COMBINING GREEK PERISPOMENI}";
2404 # Before #13843 this was failing by matching falsely.
2405 print "_:$char:_" =~ m/_:$SIGMA:_/i ? "not ok 786\n" : "ok 786\n";
2411 use charnames ':full';
2413 print "a!" =~ /^(\X)!/ && $1 eq "a" ?
2414 "ok 787\n" : "not ok 787 # $1\n";
2415 print "\xDF!" =~ /^(\X)!/ && $1 eq "\xDF" ?
2416 "ok 788\n" : "not ok 788 # $1\n";
2417 print "\x{100}!" =~ /^(\X)!/ && $1 eq "\x{100}" ?
2418 "ok 789\n" : "not ok 789 # $1\n";
2419 print "\x{100}\x{300}!" =~ /^(\X)!/ && $1 eq "\x{100}\x{300}" ?
2420 "ok 790\n" : "not ok 790 # $1\n";
2421 print "\N{LATIN CAPITAL LETTER E}!" =~ /^(\X)!/ &&
2422 $1 eq "\N{LATIN CAPITAL LETTER E}" ?
2423 "ok 791\n" : "not ok 791 # $1\n";
2424 print "\N{LATIN CAPITAL LETTER E}\N{COMBINING GRAVE ACCENT}!" =~
2426 $1 eq "\N{LATIN CAPITAL LETTER E}\N{COMBINING GRAVE ACCENT}" ?
2427 "ok 792\n" : "not ok 792 # $1\n";
2431 print "#\\C and \\X\n";
2433 print "!abc!" =~ /a\Cc/ ? "ok 793\n" : "not ok 793\n";
2434 print "!abc!" =~ /a\Xc/ ? "ok 794\n" : "not ok 794\n";
2438 print "# FINAL SIGMA\n";
2440 my $SIGMA = "\x{03A3}"; # CAPITAL
2441 my $Sigma = "\x{03C2}"; # SMALL FINAL
2442 my $sigma = "\x{03C3}"; # SMALL
2444 print $SIGMA =~ /$SIGMA/i ? "ok 795\n" : "not ok 795\n";
2445 print $SIGMA =~ /$Sigma/i ? "ok 796\n" : "not ok 796\n";
2446 print $SIGMA =~ /$sigma/i ? "ok 797\n" : "not ok 797\n";
2448 print $Sigma =~ /$SIGMA/i ? "ok 798\n" : "not ok 798\n";
2449 print $Sigma =~ /$Sigma/i ? "ok 799\n" : "not ok 799\n";
2450 print $Sigma =~ /$sigma/i ? "ok 800\n" : "not ok 800\n";
2452 print $sigma =~ /$SIGMA/i ? "ok 801\n" : "not ok 801\n";
2453 print $sigma =~ /$Sigma/i ? "ok 802\n" : "not ok 802\n";
2454 print $sigma =~ /$sigma/i ? "ok 803\n" : "not ok 803\n";
2456 print $SIGMA =~ /[$SIGMA]/i ? "ok 804\n" : "not ok 804\n";
2457 print $SIGMA =~ /[$Sigma]/i ? "ok 805\n" : "not ok 805\n";
2458 print $SIGMA =~ /[$sigma]/i ? "ok 806\n" : "not ok 806\n";
2460 print $Sigma =~ /[$SIGMA]/i ? "ok 807\n" : "not ok 807\n";
2461 print $Sigma =~ /[$Sigma]/i ? "ok 808\n" : "not ok 808\n";
2462 print $Sigma =~ /[$sigma]/i ? "ok 809\n" : "not ok 809\n";
2464 print $sigma =~ /[$SIGMA]/i ? "ok 810\n" : "not ok 810\n";
2465 print $sigma =~ /[$Sigma]/i ? "ok 811\n" : "not ok 811\n";
2466 print $sigma =~ /[$sigma]/i ? "ok 812\n" : "not ok 812\n";
2470 print "# parlez-vous?\n";
2472 use charnames ':full';
2474 print "fran\N{LATIN SMALL LETTER C}ais" =~
2477 "ok 813\n" : "not ok 813\n";
2479 print "fran\N{LATIN SMALL LETTER C WITH CEDILLA}ais" =~
2481 $& eq "fran\N{LATIN SMALL LETTER C WITH CEDILLA}ais" ?
2482 "ok 814\n" : "not ok 814\n";
2484 print "fran\N{LATIN SMALL LETTER C}ais" =~
2487 "ok 815\n" : "not ok 815\n";
2489 print "franc\N{COMBINING CEDILLA}ais" =~
2490 /franc\C\Cais/ ? # COMBINING CEDILLA is two bytes when encoded
2491 "ok 816\n" : "not ok 816\n";
2493 print "fran\N{LATIN SMALL LETTER C}ais" =~
2496 "ok 817\n" : "not ok 817\n";
2498 print "fran\N{LATIN SMALL LETTER C WITH CEDILLA}ais" =~
2500 $& eq "fran\N{LATIN SMALL LETTER C WITH CEDILLA}ais" ?
2501 "ok 818\n" : "not ok 818\n";
2503 print "franc\N{COMBINING CEDILLA}ais" =~
2505 $& eq "franc\N{COMBINING CEDILLA}ais" ?
2506 "ok 819\n" : "not ok 819\n";
2508 print "fran\N{LATIN SMALL LETTER C WITH CEDILLA}ais" =~
2509 /fran\N{LATIN SMALL LETTER C WITH CEDILLA}ais/ &&
2510 $& eq "fran\N{LATIN SMALL LETTER C WITH CEDILLA}ais" ?
2511 "ok 820\n" : "not ok 820\n";
2513 print "franc\N{COMBINING CEDILLA}ais" =~
2514 /franc\N{COMBINING CEDILLA}ais/ &&
2515 $& eq "franc\N{COMBINING CEDILLA}ais" ?
2516 "ok 821\n" : "not ok 821\n";
2518 print "fran\N{LATIN SMALL LETTER C}ais" =~
2519 /fran(?:c\N{COMBINING CEDILLA}?|\N{LATIN SMALL LETTER C WITH CEDILLA})ais/ &&
2521 "ok 822\n" : "not ok 822\n";
2523 print "fran\N{LATIN SMALL LETTER C}ais" =~
2524 /fran(?:c\N{COMBINING CEDILLA}?|\N{LATIN SMALL LETTER C WITH CEDILLA})ais/ &&
2526 "ok 823\n" : "not ok 823\n";
2528 print "fran\N{LATIN SMALL LETTER C WITH CEDILLA}ais" =~
2529 /fran(?:c\N{COMBINING CEDILLA}?|\N{LATIN SMALL LETTER C WITH CEDILLA})ais/ &&
2530 $& eq "fran\N{LATIN SMALL LETTER C WITH CEDILLA}ais" ?
2531 "ok 824\n" : "not ok 824\n";
2533 print "franc\N{COMBINING CEDILLA}ais" =~
2534 /fran(?:c\N{COMBINING CEDILLA}?|\N{LATIN SMALL LETTER C WITH CEDILLA})ais/ &&
2535 $& eq "franc\N{COMBINING CEDILLA}ais" ?
2536 "ok 825\n" : "not ok 825\n";
2540 print "# Does lingering (and useless) UTF8 flag mess up /i matching?\n";
2543 my $regex = "ABcde";
2544 my $string = "abcDE\x{100}";
2546 if ($string =~ m/$regex/i) {
2549 print "not ok 826\n";
2554 my $regex = "ABcde\x{100}";
2555 my $string = "abcDE";
2557 if ($string =~ m/$regex/i) {
2560 print "not ok 827\n";
2565 my $regex = "ABcde\x{100}";
2566 my $string = "abcDE\x{100}";
2569 if ($string =~ m/$regex/i) {
2572 print "not ok 828\n";
2578 print "# more SIGMAs\n";
2580 my $SIGMA = "\x{03A3}"; # CAPITAL
2581 my $Sigma = "\x{03C2}"; # SMALL FINAL
2582 my $sigma = "\x{03C3}"; # SMALL
2584 my $S3 = "$SIGMA$Sigma$sigma";
2586 print ":$S3:" =~ /:(($SIGMA)+):/i && $1 eq $S3 && $2 eq $sigma ?
2587 "ok 829\n" : "not ok 829\n";
2588 print ":$S3:" =~ /:(($Sigma)+):/i && $1 eq $S3 && $2 eq $sigma ?
2589 "ok 830\n" : "not ok 830\n";
2590 print ":$S3:" =~ /:(($sigma)+):/i && $1 eq $S3 && $2 eq $sigma ?
2591 "ok 831\n" : "not ok 831\n";
2593 print ":$S3:" =~ /:(([$SIGMA])+):/i && $1 eq $S3 && $2 eq $sigma ?
2594 "ok 832\n" : "not ok 832\n";
2595 print ":$S3:" =~ /:(([$Sigma])+):/i && $1 eq $S3 && $2 eq $sigma ?
2596 "ok 833\n" : "not ok 833\n";
2597 print ":$S3:" =~ /:(([$sigma])+):/i && $1 eq $S3 && $2 eq $sigma ?
2598 "ok 834\n" : "not ok 834\n";
2602 print "# LATIN SMALL LETTER SHARP S\n";
2604 use charnames ':full';
2606 print "\N{LATIN SMALL LETTER SHARP S}" =~
2607 /\N{LATIN SMALL LETTER SHARP S}/ ? "ok 835\n" : "not ok 835\n";
2609 print "\N{LATIN SMALL LETTER SHARP S}" =~
2610 /\N{LATIN SMALL LETTER SHARP S}/i ? "ok 836\n" : "not ok 836\n";
2612 print "\N{LATIN SMALL LETTER SHARP S}" =~
2613 /[\N{LATIN SMALL LETTER SHARP S}]/ ? "ok 837\n" : "not ok 837\n";
2615 print "\N{LATIN SMALL LETTER SHARP S}" =~
2616 /[\N{LATIN SMALL LETTER SHARP S}]/i ? "ok 838\n" : "not ok 838\n";
2619 /\N{LATIN SMALL LETTER SHARP S}/i ? "ok 839\n" : "not ok 839\n";
2622 /\N{LATIN SMALL LETTER SHARP S}/i ? "ok 840\n" : "not ok 840\n";
2625 /[\N{LATIN SMALL LETTER SHARP S}]/i ? "ok 841\n" : "not ok 841\n";
2628 /[\N{LATIN SMALL LETTER SHARP S}]/i ? "ok 842\n" : "not ok 842\n";
2630 print "\N{LATIN SMALL LETTER SHARP S}" =~ /ss/i ?
2631 "ok 843\n" : "not ok 843\n";
2633 print "\N{LATIN SMALL LETTER SHARP S}" =~ /SS/i ?
2634 "ok 844\n" : "not ok 844\n";
2638 print "# more whitespace: U+0085, U+2028, U+2029\n";
2640 # U+0085 needs to be forced to be Unicode, the \x{100} does that.
2641 print "<\x{100}\x{0085}>" =~ /<\x{100}\s>/ ? "ok 845\n" : "not ok 845\n";
2642 print "<\x{2028}>" =~ /<\s>/ ? "ok 846\n" : "not ok 846\n";
2643 print "<\x{2029}>" =~ /<\s>/ ? "ok 847\n" : "not ok 847\n";
2647 print "# . with /s should work on characters, as opposed to bytes\n";
2649 my $s = "\x{e4}\x{100}";
2651 # This is not expected to match: the point is that
2652 # neither should we get "Malformed UTF-8" warnings.
2653 print $s =~ /\G(.+?)\n/gcs ?
2654 "not ok 848\n" : "ok 848\n";
2658 while ($s =~ /\G(.)/gs) {
2662 print join("", @c) eq $s ? "ok 849\n" : "not ok 849\n";
2664 my $t1 = "Q003\n\n\x{e4}\x{f6}\n\nQ004\n\n\x{e7}"; # test only chars < 256
2666 while ($t1 =~ / \G ( .+? ) \n\s+ ( .+? ) ( $ | \n\s+ ) /xgcs) {
2670 my $t2 = $t1 . "\x{100}"; # repeat with a larger char
2672 while ($t2 =~ / \G ( .+? ) \n\s+ ( .+? ) ( $ | \n\s+ ) /xgcs) {
2676 print $r1 eq $r2 ? "ok 850\n" : "not ok 850\n";
2680 print "# Unicode lookbehind\n";
2682 print "A\x{100}B" =~ /(?<=A.)B/ ? "ok 851\n" : "not ok 851\n";
2683 print "A\x{200}\x{300}B" =~ /(?<=A..)B/ ? "ok 852\n" : "not ok 852\n";
2684 print "\x{400}AB" =~ /(?<=\x{400}.)B/ ? "ok 853\n" : "not ok 853\n";
2685 print "\x{500\x{600}}B" =~ /(?<=\x{500}.)B/ ? "ok 854\n" : "not ok 854\n";
2689 print "# UTF-8 hash keys and /\$/\n";
2690 # http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2002-01/msg01327.html
2693 my $v = substr($u,0,1);
2694 my $w = substr($u,1,1);
2695 my %u = ( $u => $u, $v => $v, $w => $w );
2698 my $m1 = /^\w*$/ ? 1 : 0;
2699 my $m2 = $u{$_}=~/^\w*$/ ? 1 : 0;
2700 print $m1 == $m2 ? "ok $i\n" : "not ok $i # $m1 $m2\n";
2706 print "# [ID 20020124.005]\n";
2709 for my $char ("a", "\x{df}", "\x{100}"){
2710 $x = "$char b $char";
2715 print substr($x,0,1) eq substr($x,-1,1) ?
2716 "ok $i\n" : "not ok $i # debug: $x\n";
2722 print "# SEGV in s/// and UTF-8\n";
2723 $s = "s#\x{100}" x 4;
2725 print $s eq "s \x{100}" x 4 ? "ok 861\n" : "not ok 861\n";
2729 print "# UTF-8 bug (maybe alreayd known?)\n";
2733 $u =~ s/./\x{100}/g;
2734 print $u eq "\x{100}\x{100}\x{100}" ? "ok 862\n" : "not ok 862\n";
2737 $u =~ s/[ao]/\x{100}/g;
2738 print $u eq "f\x{100}\x{100}b\x{100}r" ? "ok 863\n" : "not ok 863\n";
2740 $u =~ s/\x{100}/e/g;
2741 print $u eq "feeber" ? "ok 864\n" : "not ok 864\n";
2745 print "# UTF-8 bug with s///\n";
2746 # check utf8/non-utf8 mixtures
2747 # try to force all float/anchored check combinations
2752 "xx.*$c", "x.*$c$c", "$c.*xx", "$c$c.*x", "xx.*(?=$c)", "(?=$c).*xx",
2754 print "xxx" =~ /$re/ ? "not ok $test\n" : "ok $test\n";
2756 print +($subst = "xxx") =~ s/$re// ? "not ok $test\n" : "ok $test\n";
2759 for my $re ("xx.*$c*", "$c*.*xx") {
2760 print "xxx" =~ /$re/ ? "ok $test\n" : "not ok $test\n";
2762 ($subst = "xxx") =~ s/$re//;
2763 print $subst eq '' ? "ok $test\n" : "not ok $test\t# $subst\n";
2766 for my $re ("xxy*", "y*xx") {
2767 print "xx$c" =~ /$re/ ? "ok $test\n" : "not ok $test\n";
2769 ($subst = "xx$c") =~ s/$re//;
2770 print $subst eq $c ? "ok $test\n" : "not ok $test\n";
2772 print "xy$c" =~ /$re/ ? "not ok $test\n" : "ok $test\n";
2774 print +($subst = "xy$c") =~ /$re/ ? "not ok $test\n" : "ok $test\n";
2777 for my $re ("xy$c*z", "x$c*yz") {
2778 print "xyz" =~ /$re/ ? "ok $test\n" : "not ok $test\n";
2780 ($subst = "xyz") =~ s/$re//;
2781 print $subst eq '' ? "ok $test\n" : "not ok $test\n";
2787 print "# qr/.../x\n";
2790 my $R = qr/ A B C # D E/x;
2792 print eval {"ABCDE" =~ $R} ? "ok $test\n" : "not ok $test\n";
2795 print eval {"ABCDE" =~ m/$R/} ? "ok $test\n" : "not ok $test\n";
2798 print eval {"ABCDE" =~ m/($R)/} ? "ok $test\n" : "not ok $test\n";
2803 print "# illegal Unicode properties\n";
2806 print eval { "a" =~ /\pq / } ? "not ok $test\n" : "ok $test\n";
2809 print eval { "a" =~ /\p{qrst} / } ? "not ok $test\n" : "ok $test\n";
2814 print "# [ID 20020412.005] wrong pmop flags checked when empty pattern\n";
2815 # requires reuse of last successful pattern
2823 printf "not ok %s\t# 'match once' %s on %s iteration\n", $test,
2824 $match ? 'succeeded' : 'failed', $_ ? 'second' : 'first';
2829 my $result = join '', $test =~ //g;
2830 if ($result eq $test) {
2833 printf "not ok %s\t# expected '%s', got '%s'\n", $test, $test, $result;
2838 print "# user-defined character properties\n";
2872 print "\x{3040}" =~ /\p{InKana1}/ ? "ok $test\n" : "not ok $test\n"; $test++;
2873 print "\x{303F}" =~ /\P{InKana1}/ ? "ok $test\n" : "not ok $test\n"; $test++;
2875 print "\x{3040}" =~ /\p{InKana2}/ ? "ok $test\n" : "not ok $test\n"; $test++;
2876 print "\x{303F}" =~ /\P{InKana2}/ ? "ok $test\n" : "not ok $test\n"; $test++;
2878 print "\x{3041}" =~ /\p{InKana3}/ ? "ok $test\n" : "not ok $test\n"; $test++;
2879 print "\x{3040}" =~ /\P{InKana3}/ ? "ok $test\n" : "not ok $test\n"; $test++;
2881 print "\x{3040}" =~ /\p{InNotKana}/ ? "ok $test\n" : "not ok $test\n"; $test++;
2882 print "\x{3041}" =~ /\P{InNotKana}/ ? "ok $test\n" : "not ok $test\n"; $test++;
2884 sub InConsonant { # Not EBCDIC-aware.
2895 print "d" =~ /\p{InConsonant}/ ? "ok $test\n" : "not ok $test\n"; $test++;
2896 print "e" =~ /\P{InConsonant}/ ? "ok $test\n" : "not ok $test\n"; $test++;
2899 print "# [ID 20020630.002] utf8 regex only matches 32k\n";
2901 for ([ 'byte', "\x{ff}" ], [ 'utf8', "\x{1ff}" ]) {
2902 my($type, $char) = @$_;
2903 for my $len (32000, 32768, 33000) {
2904 my $s = $char . "f" x $len;
2905 my $r = $s =~ /$char([f]*)/gc;
2906 print $r ? "ok $test\n" : "not ok $test\t# <$type x $len> fail\n";
2908 print +(!$r or pos($s) == $len + 1) ? "ok $test\n"
2909 : "not ok $test\t# <$type x $len> pos @{[ pos($s) ]}\n";
2917 $a = bless qr/foo/, 'Foo';
2918 print(('goodfood' =~ $a ? '' : 'not '),
2919 "ok $test\t# reblessed qr// matches\n");
2922 print(($a eq '(?-xism:foo)' ? '' : 'not '),
2923 "ok $test\t# reblessed qr// stringizes\n");
2927 $z=$y = "\317\276"; # $y is byte representation of $x
2930 print(($x =~ $a ? '' : 'not '), "ok $test - utf8 interpolation in qr//\n");
2933 print(("a$a" =~ $x ? '' : 'not '),
2934 "ok $test - stringifed qr// preserves utf8\n");
2937 print(("a$x" =~ /^a$a\z/ ? '' : 'not '),
2938 "ok $test - interpolated qr// preserves utf8\n");
2941 print(("a$x" =~ /^a(??{$a})\z/ ? '' : 'not '),
2942 "ok $test - postponed interpolation of qr// preserves utf8\n");
2945 print((length(qr/##/x) == 12 ? '' : 'not '),
2946 "ok $test - ## in qr// doesn't corrupt memory [perl #17776]\n");
2951 print(("$x$x" =~ /^$x(??{$x})\z/ ? '' : 'not '),
2952 "ok $test - postponed utf8 string in utf8 re matches utf8\n");
2955 print(("$y$x" =~ /^$y(??{$x})\z/ ? '' : 'not '),
2956 "ok $test - postponed utf8 string in non-utf8 re matches utf8\n");
2959 print(("$y$x" !~ /^$y(??{$y})\z/ ? '' : 'not '),
2960 "ok $test - postponed non-utf8 string in non-utf8 re doesn't match utf8\n");
2963 print(("$x$x" !~ /^$x(??{$y})\z/ ? '' : 'not '),
2964 "ok $test - postponed non-utf8 string in utf8 re doesn't match utf8\n");
2967 print(("$y$y" =~ /^$y(??{$y})\z/ ? '' : 'not '),
2968 "ok $test - postponed non-utf8 string in non-utf8 re matches non-utf8\n");
2971 print(("$x$y" =~ /^$x(??{$y})\z/ ? '' : 'not '),
2972 "ok $test - postponed non-utf8 string in utf8 re matches non-utf8\n");
2974 $y = $z; # reset $y after upgrade
2976 print(("$x$y" !~ /^$x(??{$x})\z/ ? '' : 'not '),
2977 "ok $test - postponed utf8 string in utf8 re doesn't match non-utf8\n");
2979 $y = $z; # reset $y after upgrade
2981 print(("$y$y" !~ /^$y(??{$x})\z/ ? '' : 'not '),
2982 "ok $test - postponed utf8 string in non-utf8 re doesn't match non-utf8\n");
2987 print "# more user-defined character properties\n";
2996 print "\x{0712}" =~ /\p{IsSyriac1}/ ? "ok $test\n" : "not ok $test\n"; $test++;
2997 print "\x{072F}" =~ /\P{IsSyriac1}/ ? "ok $test\n" : "not ok $test\n"; $test++;
3006 print "\x{0712}" =~ /\p{Syriac1}/ ? "ok $test\n" : "not ok $test\n"; $test++;
3007 print "\x{072F}" =~ /\P{Syriac1}/ ? "ok $test\n" : "not ok $test\n"; $test++;
3010 print "# Change #18179\n";
3011 # previously failed with "panic: end_shift
3012 my $s = "\x{100}" x 5;
3013 my $ok = $s =~ /(\x{100}{4})/;
3014 my($ord, $len) = (ord $1, length $1);
3015 print +($ok && $ord == 0x100 && $len == 4)
3016 ? "ok $test\n" : "not ok $test\t# $ok/$ord/$len\n";
3021 print "# [perl #15763]\n";
3024 chop $a; # but leaves the UTF-8 flag
3025 $a .= "y"; # 1 byte before "y"
3027 ok($a =~ /^\C/, 'match one \C on 1-byte UTF-8');
3028 ok($a =~ /^\C{1}/, 'match \C{1}');
3030 ok($a =~ /^\Cy/, 'match \Cy');
3031 ok($a =~ /^\C{1}y/, 'match \C{1}y');
3033 $a = "\x{100}y"; # 2 bytes before "y"
3035 ok($a =~ /^\C/, 'match one \C on 2-byte UTF-8');
3036 ok($a =~ /^\C{1}/, 'match \C{1}');
3037 ok($a =~ /^\C\C/, 'match two \C');
3038 ok($a =~ /^\C{2}/, 'match \C{2}');
3040 ok($a =~ /^\C\C\C/, 'match three \C on 2-byte UTF-8 and a byte');
3041 ok($a =~ /^\C{3}/, 'match \C{3}');
3043 ok($a =~ /^\C\Cy/, 'match two \C');
3044 ok($a =~ /^\C{2}y/, 'match \C{2}');
3046 ok($a !~ /^\C\C\Cy/, q{don't match three \Cy});
3047 ok($a !~ /^\C{2}\Cy/, q{don't match \C{3}y});
3049 $a = "\x{1000}y"; # 3 bytes before "y"
3051 ok($a =~ /^\C/, 'match one \C on three-byte UTF-8');
3052 ok($a =~ /^\C{1}/, 'match \C{1}');
3053 ok($a =~ /^\C\C/, 'match two \C');
3054 ok($a =~ /^\C{2}/, 'match \C{2}');
3055 ok($a =~ /^\C\C\C/, 'match three \C');
3056 ok($a =~ /^\C{3}/, 'match \C{3}');
3058 ok($a =~ /^\C\C\C\C/, 'match four \C on three-byte UTF-8 and a byte');
3059 ok($a =~ /^\C{4}/, 'match \C{4}');
3061 ok($a =~ /^\C\C\Cy/, 'match three \Cy');
3062 ok($a =~ /^\C{3}y/, 'match \C{3}y');
3064 ok($a !~ /^\C\C\C\C\y/, q{don't match four \Cy});
3065 ok($a !~ /^\C{4}y/, q{don't match \C{4}y});
3069 utf8::upgrade($_); chop $_; $\="\n";
3070 ok(/[^\s]+/, "m/[^\s]/ utf8");
3071 ok(/[^\d]+/, "m/[^\d]/ utf8");
3072 ok(($a = $_, $_ =~ s/[^\s]+/./g), "s/[^\s]/ utf8");
3073 ok(($a = $_, $a =~ s/[^\d]+/./g), "s/[^\s]/ utf8");
3075 ok("\x{100}" =~ /\x{100}/, "[perl #15397]");
3076 ok("\x{100}" =~ /(\x{100})/, "[perl #15397]");
3077 ok("\x{100}" =~ /(\x{100}){1}/, "[perl #15397]");
3078 ok("\x{100}\x{100}" =~ /(\x{100}){2}/, "[perl #15397]");
3079 ok("\x{100}\x{100}" =~ /(\x{100})(\x{100})/, "[perl #15397]");
3083 ok(!defined $1, "[perl #7471]");
3087 ok(!defined $1, "[perl #7471]");
3089 $pattern = "^(b+?|a){1,2}c";
3090 ok("bac" =~ /$pattern/ && $1 eq 'a', "[perl #3547]");
3091 ok("bbac" =~ /$pattern/ && $1 eq 'a', "[perl #3547]");
3092 ok("bbbac" =~ /$pattern/ && $1 eq 'a', "[perl #3547]");
3093 ok("bbbbac" =~ /$pattern/ && $1 eq 'a', "[perl #3547]");
3098 ok( $1 eq "\x{100}", '$1 is utf-8 [perl #18232]' );
3100 ok( $1 eq "\x{100}", '$1 is still utf-8' );
3101 ok( $1 ne "\xC4\x80", '$1 is not non-utf-8' );
3106 my $attr = 'Name-1' ;
3108 my $NormalChar = qr/[\p{IsDigit}\p{IsLower}\p{IsUpper}]/;
3109 my $NormalWord = qr/${NormalChar}+?/;
3110 my $PredNameHyphen = qr/^${NormalWord}(\-${NormalWord})*?$/;
3113 ok( $attr =~ $PredNameHyphen, "[perl #19767] original test" );
3119 ok ( "0" =~ /\p{N}+\z/, "[perl #19767] variant test" );
3126 $p++ if /(??{ $p })/
3128 ok ($p == 5, "[perl #20683] (??{ }) returns stale values");
3129 { package P; $a=1; sub TIESCALAR { bless[] } sub FETCH { $a++ } }
3134 ok ( $p == 5, "(??{ }) returns stale values");
3138 # Subject: Odd regexp behavior
3139 # From: Markus Kuhn <Markus.Kuhn@cl.cam.ac.uk>
3140 # Date: Wed, 26 Feb 2003 16:53:12 +0000
3141 # Message-Id: <E18o4nw-0008Ly-00@wisbech.cl.cam.ac.uk>
3142 # To: perl-unicode@perl.org
3144 $x = "\x{2019}\nk"; $x =~ s/(\S)\n(\S)/$1 $2/sg;
3145 ok($x eq "\x{2019} k", "Markus Kuhn 2003-02-26");
3147 $x = "b\nk"; $x =~ s/(\S)\n(\S)/$1 $2/sg;
3148 ok($x eq "b k", "Markus Kuhn 2003-02-26");
3150 ok("\x{2019}" =~ /\S/, "Markus Kuhn 2003-02-26");
3155 ok('-1-3-5-' eq join('', split /((??{$i++}))/, '-1-3-5-'),
3156 "[perl #21411] (??{ .. }) corrupts split's stack");
3157 split /(?{'WOW'})/, 'abc';
3158 ok('a|b|c' eq join ('|', @_),
3159 "[perl #21411] (?{ .. }) version of the above");
3163 split /(?{ split "" })/, "abc";
3164 ok(1,'cache_re & "(?{": it dumps core in 5.6.1 & 5.8.0');
3168 ok("\x{100}\n" =~ /\x{100}\n$/, "UTF8 length cache and fbm_compile");
3173 use overload q/""/ => sub { ${$_[0]}; };
3174 sub new { my ($c, $v) = @_; bless \$v, $c; }
3177 $_ = Str->new("a\x{100}/\x{100}b");
3178 ok(join(":", /\b(.)\x{100}/g) eq "a:/", "re_intuit_start and PL_bostr");
3182 $_ = "code: 'x' { '...' }\n"; study;
3183 my @x; push @x, $& while m/'[^\']*'/gx;
3184 ok(join(":", @x) eq "'x':'...'",
3185 "[perl #17757] Parse::RecDescent triggers infinite loop");
3189 my $re = qq/^([^X]*)X/;
3191 ok("\x{100}X" =~ /$re/, "S_cl_and ANYOF_UNICODE & ANYOF_INVERTED");
3196 ok( "a\nb" !~ /^b/, $_[0] );
3197 ok( "a\nb" =~ /^b/m, "$_[0] - with /m" );
3200 $_ = "x"; s/x/func "in subst"/e;
3201 $_ = "x"; s/x/func "in multiline subst"/em;
3202 #$_ = "x"; /x(?{func "in regexp"})/;
3203 #$_ = "x"; /x(?{func "in multiline regexp"})/m;
3208 ok("abcde" eq "$`", '# TODO #19049 - global match not setting $`');
3210 ok("123\x{100}" =~ /^.*1.*23\x{100}$/, 'uft8 + multiple floating substr');
3212 # LATIN SMALL/CAPITAL LETTER A WITH MACRON
3213 ok(" \x{101}" =~ qr/\x{100}/i,
3214 "<20030808193656.5109.1@llama.ni-s.u-net.com>");
3216 # LATIN SMALL/CAPITAL LETTER A WITH RING BELOW
3217 ok(" \x{1E01}" =~ qr/\x{1E00}/i,
3218 "<20030808193656.5109.1@llama.ni-s.u-net.com>");
3220 # DESERET SMALL/CAPITAL LETTER LONG I
3221 ok(" \x{10428}" =~ qr/\x{10400}/i,
3222 "<20030808193656.5109.1@llama.ni-s.u-net.com>");
3224 # LATIN SMALL/CAPITAL LETTER A WITH RING BELOW + 'X'
3225 ok(" \x{1E01}x" =~ qr/\x{1E00}X/i,
3226 "<20030808193656.5109.1@llama.ni-s.u-net.com>");
3229 # [perl #23769] Unicode regex broken on simple example
3230 # regrepeat() didn't handle UTF-8 EXACT case right.
3232 my $s = "\x{a0}\x{a0}\x{a0}\x{100}"; chop $s;
3234 ok($s =~ /\x{a0}/, "[perl #23769]");
3235 ok($s =~ /\x{a0}+/, "[perl #23769]");
3236 ok($s =~ /\x{a0}\x{a0}/, "[perl #23769]");
3238 ok("aaa\x{100}" =~ /(a+)/, "[perl #23769] easy invariant");
3239 ok($1 eq "aaa", "[perl #23769]");
3241 ok("\xa0\xa0\xa0\x{100}" =~ /(\xa0+)/, "[perl #23769] regrepeat invariant");
3242 ok($1 eq "\xa0\xa0\xa0", "[perl #23769]");
3244 ok("ababab\x{100} " =~ /((?:ab)+)/, "[perl #23769] hard invariant");
3245 ok($1 eq "ababab", "[perl #23769]");
3247 ok("\xa0\xa1\xa0\xa1\xa0\xa1\x{100}" =~ /((?:\xa0\xa1)+)/, "[perl #23769] hard variant");
3248 ok($1 eq "\xa0\xa1\xa0\xa1\xa0\xa1", "[perl #23769]");
3250 ok("aaa\x{100} " =~ /(a+?)/, "[perl #23769] easy invariant");
3251 ok($1 eq "a", "[perl #23769]");
3253 ok("\xa0\xa0\xa0\x{100} " =~ /(\xa0+?)/, "[perl #23769] regrepeat variant");
3254 ok($1 eq "\xa0", "[perl #23769]");
3256 ok("ababab\x{100} " =~ /((?:ab)+?)/, "[perl #23769] hard invariant");
3257 ok($1 eq "ab", "[perl #23769]");
3259 ok("\xa0\xa1\xa0\xa1\xa0\xa1\x{100}" =~ /((?:\xa0\xa1)+?)/, "[perl #23769] hard variant");
3260 ok($1 eq "\xa0\xa1", "[perl #23769]");
3262 ok("\xc4\xc4\xc4" !~ /(\x{100}+)/, "[perl #23769] don't match first byte of utf8 representation");
3263 ok("\xc4\xc4\xc4" !~ /(\x{100}+?)/, "[perl #23769] don't match first byte of utf8 representation");
3267 my $head = 'x' x $_;
3268 for my $tail ('\x{0061}', '\x{1234}') {
3270 eval qq{ "$head$tail" =~ /$head$tail/ },
3271 '\x{...} misparsed in regexp near 127 char EXACT limit'
3276 # perl #25269: panic: pp_match start/end pointers
3278 my($x, $y) = "bca" =~ /^(?=.*(a)).*(bc)/;
3280 }, 'captures can move backwards in string');
3282 # perl #27940: \cA not recognized in character classes
3283 ok("a\cAb" =~ /\cA/, '\cA in pattern');
3284 ok("a\cAb" =~ /[\cA]/, '\cA in character class');
3285 ok("a\cAb" =~ /[\cA-\cB]/, '\cA in character class range');
3286 ok("abc" =~ /[^\cA-\cB]/, '\cA in negated character class range');
3287 ok("a\cBb" =~ /[\cA-\cC]/, '\cB in character class range');
3288 ok("a\cCbc" =~ /[^\cA-\cB]/, '\cC in negated character class range');
3289 ok("a\cAb" =~ /(??{"\cA"})/, '\cA in ??{} pattern');
3291 # perl #28532: optional zero-width match at end of string is ignored
3292 ok(("abc" =~ /^abc(\z)?/) && defined($1),
3293 'optional zero-width match at end of string');
3294 ok(("abc" =~ /^abc(\z)??/) && !defined($1),
3295 'optional zero-width match at end of string');
3301 "words"=~/(word|word|word)(?{push @got,$1})s$/;
3302 ok(@got==1,"TRIE optimation is working") or warn "# @got";
3304 "words"=~/(word|word|word)(?{push @got,$1})s$/i;
3305 ok(@got==1,"TRIEF optimisation is working") or warn "# @got";
3307 my @nums=map {int rand 1000} 1..100;
3308 my $re="(".(join "|",@nums).")";
3312 ok($_=~/$re/,"Trie nums");
3316 push @got,$1 while /$re/g;
3319 $count{$_}++ for @got;
3322 $ok=0 if --$count{$_}<0;
3324 ok($ok,"Trie min count matches");
3329 # LATIN SMALL/CAPITAL LETTER A WITH MACRON
3330 ok(("foba \x{101}foo" =~ qr/(foo|\x{100}foo|bar)/i) && $1 eq "\x{101}foo",
3331 "TRIEF + LATIN SMALL/CAPITAL LETTER A WITH MACRON");
3333 # LATIN SMALL/CAPITAL LETTER A WITH RING BELOW
3334 ok(("foba \x{1E01}foo" =~ qr/(foo|\x{1E00}foo|bar)/i) && $1 eq "\x{1E01}foo",
3335 "TRIEF + LATIN SMALL/CAPITAL LETTER A WITH RING BELOW");
3337 # DESERET SMALL/CAPITAL LETTER LONG I
3338 ok(("foba \x{10428}foo" =~ qr/(foo|\x{10400}foo|bar)/i) && $1 eq "\x{10428}foo",
3339 "TRIEF + DESERET SMALL/CAPITAL LETTER LONG I");
3341 # LATIN SMALL/CAPITAL LETTER A WITH RING BELOW + 'X'
3342 ok(("foba \x{1E01}xfoo" =~ qr/(foo|\x{1E00}Xfoo|bar)/i) && $1 eq "\x{1E01}xfoo",
3343 "TRIEF + LATIN SMALL/CAPITAL LETTER A WITH RING BELOW + 'X'");
3347 use charnames ':full';
3349 $s="\N{LATIN SMALL LETTER SHARP S}";
3350 ok(("foba ba$s" =~ qr/(foo|Ba$s|bar)/i)
3352 "TRIEF + LATIN SMALL LETTER SHARP S =~ ss");
3353 ok(("foba ba$s" =~ qr/(Ba$s|foo|bar)/i)
3355 "TRIEF + LATIN SMALL LETTER SHARP S =~ ss");
3356 ok(("foba ba$s" =~ qr/(foo|bar|Ba$s)/i)
3358 "TRIEF + LATIN SMALL LETTER SHARP S =~ ss");
3360 ok(("foba ba$s" =~ qr/(foo|Bass|bar)/i)
3362 "TRIEF + LATIN SMALL LETTER SHARP S =~ ss");
3364 ok(("foba ba$s" =~ qr/(foo|BaSS|bar)/i)
3366 "TRIEF + LATIN SMALL LETTER SHARP S =~ SS");
3372 my @normal=qw(these are some normal words);
3373 my $psycho=join "|",@normal,map chr $_,255..20000;
3374 ok(('these'=~/($psycho)/) && $1 eq 'these','Pyscho');
3377 # [perl #36207] mixed utf8 / latin-1 and case folding
3380 my $utf8 = "\xe9\x{100}"; chop $utf8;
3381 my $latin1 = "\xe9";
3383 ok($utf8 =~ /\xe9/i, "utf8/latin");
3384 ok($utf8 =~ /$latin1/i, "utf8/latin runtime");
3385 ok($utf8 =~ /(abc|\xe9)/i, "utf8/latin trie");
3386 ok($utf8 =~ /(abc|$latin1)/i, "utf8/latin trie runtime");
3388 ok("\xe9" =~ /$utf8/i, "# TODO latin/utf8");
3389 ok("\xe9" =~ /(abc|$utf8)/i, "# latin/utf8 trie");
3390 ok($latin1 =~ /$utf8/i, "# TODO latin/utf8 runtime");
3391 ok($latin1 =~ /(abc|$utf8)/i, "# latin/utf8 trie runtime");
3394 # [perl #37038] Global regular matches generate invalid pointers
3402 "# TODO assigning to original string should not corrupt match vars");