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");
82 /not ok 26/ && reset 'X';
85 while (($key,$val) = each(%XXX)) {
94 if ($& eq 'xyz') {print "ok 28\n";} else {print "not ok 28\n";}
99 if ($& eq 'xyz') {print "ok 29\n";} else {print "not ok 29\n";}
104 if ($& eq 'xyz') {print "ok 30\n";} else {print "not ok 30\n";}
107 /def/; # optimized up to cmd
108 if ("$`:$&:$'" eq 'abc:def:ghi') {print "ok 31\n";} else {print "not ok 31\n";}
110 /cde/ + 0; # optimized only to spat
111 if ("$`:$&:$'" eq 'ab:cde:fghi') {print "ok 32\n";} else {print "not ok 32\n";}
113 /[d][e][f]/; # not optimized
114 if ("$`:$&:$'" eq 'abc:def:ghi') {print "ok 33\n";} else {print "not ok 33\n";}
116 $_ = 'now is the {time for all} good men to come to.';
118 if ($1 eq 'time for all') {print "ok 34\n";} else {print "not ok 34 $1\n";}
120 $_ = 'xxx {3,4} yyy zzz';
121 print /( {3,4})/ ? "ok 35\n" : "not ok 35\n";
122 print $1 eq ' ' ? "ok 36\n" : "not ok 36\n";
123 print /( {4,})/ ? "not ok 37\n" : "ok 37\n";
124 print /( {2,3}.)/ ? "ok 38\n" : "not ok 38\n";
125 print $1 eq ' y' ? "ok 39\n" : "not ok 39\n";
126 print /(y{2,3}.)/ ? "ok 40\n" : "not ok 40\n";
127 print $1 eq 'yyy ' ? "ok 41\n" : "not ok 41\n";
128 print /x {3,4}/ ? "not ok 42\n" : "ok 42\n";
129 print /^xxx {3,4}/ ? "not ok 43\n" : "ok 43\n";
131 $_ = "now is the time for all good men to come to.";
133 print join(':',@words) eq "now:is:the:time:for:all:good:men:to:come:to"
141 print join(':',@words) eq "now:is:the:time:for:all:good:men:to:come:to"
150 print join(':',@words) eq "to:to"
152 : "not ok 46 `@words'\n";
156 print join(':',@words) eq "to:to"
158 : "not ok 47 `@words'\n";
172 $t1=$t2=$t3=$t4=$t5=$t6=$t7=$t8=$t9=0;
186 $x = "$t1$t2$t3$t4$t5$t6$t7$t8$t9";
187 print $x eq '505550555' ? "ok 48\n" : "not ok 48 $x\n";
190 print "abc" =~ /^abc$|$xyz/ ? "ok 49\n" : "not ok 49\n";
192 # perl 4.009 says "unmatched ()"
193 eval '"abc" =~ /a(bc$)|$xyz/; $result = "$&:$1"';
194 print $@ eq "" ? "ok 50\n" : "not ok 50\n";
195 print $result eq "abc:bc" ? "ok 51\n" : "not ok 51\n";
200 print $` eq "" ? "ok 52\n" : "not ok 52\n" if $x;
202 print $` eq "abcfoo" ? "ok 53\n" : "not ok 53\n" if $x;
204 print $x == 0 ? "ok 54\n" : "not ok 54\n";
207 print $` eq "" ? "ok 55\n" : "not ok 55\n" if $x;
209 print $` eq "abcfoo" ? "ok 56\n" : "not ok 56\n" if $x;
211 print $x == 0 ? "ok 57\n" : "not ok 57\n";
214 print $' eq "fooabcbar" ? "ok 58\n" : "not ok 58\n" if $x;
216 print $' eq "bar" ? "ok 59\n" : "not ok 59\n" if $x;
219 print scalar @x == 2 ? "ok 60\n" : "not ok 60\n";
224 print "not " if (pos $_) != 2;
227 print "not " if defined pos $_;
231 'abc' =~ m'a(?{ $out = 2 })b';
232 print "not " if $out != 2;
236 'abc' =~ m'a(?{ $out = 3 })c';
237 print "not " if $out != 1;
240 $_ = 'foobar1 bar2 foobar3 barfoobar5 foobar6';
241 @out = /(?<!foo)bar./g;
242 print "not " if "@out" ne 'bar2 barf';
245 # Tests which depend on REG_INFTY
246 $reg_infty = defined $Config{reg_infty} ? $Config{reg_infty} : 32767;
247 $reg_infty_m = $reg_infty - 1; $reg_infty_p = $reg_infty + 1;
249 # As well as failing if the pattern matches do unexpected things, the
250 # next three tests will fail if you should have picked up a lower-than-
251 # default value for $reg_infty from Config.pm, but have not.
254 print "not " if eval q(('aaa' =~ /(a{1,$reg_infty_m})/)[0] ne 'aaa') || $@;
258 print "not " if eval q(('a' x $reg_infty_m) !~ /a{$reg_infty_m}/) || $@;
262 print "not " if eval q(('a' x ($reg_infty_m - 1)) =~ /a{$reg_infty_m}/) || $@;
266 eval "'aaa' =~ /a{1,$reg_infty}/";
267 print "not " if $@ !~ m%^\QQuantifier in {,} bigger than%;
270 eval "'aaa' =~ /a{1,$reg_infty_p}/";
272 if $@ !~ m%^\QQuantifier in {,} bigger than%;
276 # Poke a couple more parse failures
278 $context = 'x' x 256;
279 eval qq("${context}y" =~ /(?<=$context)y/);
280 print "not " if $@ !~ m%^\QLookbehind longer than 255 not%;
288 for $l (125, 140, 250, 270, 300000, 30) { # Ordered to free memory
290 print "# length=$l\nnot " unless "ba$a=" =~ /a$a=/;
294 print "not " if "b$a=" =~ /a$a=/;
299 # 20000 nodes, each taking 3 words per string, and 1 per branch
300 $long_constant_len = join '|', 12120 .. 32645;
301 $long_var_len = join '|', 8120 .. 28645;
302 %ans = ( 'ax13876y25677lbc' => 1,
303 'ax13876y25677mcb' => 0, # not b.
304 'ax13876y35677nbc' => 0, # Num too big
305 'ax13876y25677y21378obc' => 1,
306 'ax13876y25677y21378zbc' => 0, # Not followed by [k-o]
307 'ax13876y25677y21378y21378kbc' => 1,
308 'ax13876y25677y21378y21378kcb' => 0, # Not b.
309 'ax13876y25677y21378y21378y21378kbc' => 0, # 5 runs
313 print "# const-len `$_' not => $ans{$_}\nnot "
314 if $ans{$_} xor /a(?=([yx]($long_constant_len)){2,4}[k-o]).*b./o;
317 print "# var-len `$_' not => $ans{$_}\nnot "
318 if $ans{$_} xor /a(?=([yx]($long_var_len)){2,4}[k-o]).*b./o;
323 $_ = " a (bla()) and x(y b((l)u((e))) and b(l(e)e)e";
324 $expect = "(bla()) ((l)u((e))) (l(e)e)";
330 (?{ $c = 1 }) # Initialize
332 (?(?{ $c == 0 }) # PREVIOUS iteration was OK, stop the loop
334 ) # Fail: will unwind one iteration back
337 [^()]+ # Match a big chunk
340 ) # Do not try to match subchunks
348 )+ # This may not match with different subblocks
353 ) # Otherwise the chunk 1 may succeed with $c>0
358 push @ans, $res while $res = matchit;
360 print "# ans='@ans'\n# expect='$expect'\nnot " if "@ans" ne "1 1 1";
366 print "# ans='@ans'\n# expect='$expect'\nnot " if "@ans" ne $expect;
370 print "not " unless "abc" =~ /^(??{"a"})b/;
375 $matched = qr/\((?:(?>[^()]+)|(??{$matched}))*\)/;
378 push(@ans, $res), push(@ans1, $&) while $res = m/$matched/g;
380 print "# ans='@ans'\n# expect='$expect'\nnot " if "@ans" ne "1 1 1";
384 print "# ans1='@ans1'\n# expect='$expect'\nnot " if "@ans1" ne $expect;
390 print "# ans='@ans'\n# expect='$expect'\nnot " if "@ans" ne $expect;
394 @ans = ('a/b' =~ m%(.*/)?(.*)%); # Stack may be bad
395 print "not " if "@ans" ne 'a/ b';
399 $code = '{$blah = 45}';
402 print "not " unless $@ and $@ =~ /not allowed at runtime/ and $blah == 12;
406 for $code ('{$blah = 45}','=xx') {
408 $res = eval { "xx" =~ /(?$code)/o };
409 if ($code eq '=xx') {
410 print "#'$@','$res','$blah'\nnot " unless not $@ and $res;
412 print "#'$@','$res','$blah'\nnot " unless $@ and $@ =~ /not allowed at runtime/ and $blah == 12;
418 $code = '{$blah = 45}';
421 print "not " if $blah != 45;
427 print "not " if $blah != 45;
433 print "not " unless pos($x) == 2;
438 print "not " unless pos($x) == 2;
448 print "not " unless f(pos($x)) == 4;
453 'foot' =~ /foo(?{$x = 12; 75})[t]/;
454 print "not " unless $^R eq '75';
459 'foot' =~ /foo(?{$x = 12; 75})[xy]/;
460 print "not " unless $^R eq '67' and $x eq '12';
465 'foot' =~ /foo(?{ $^R + 12 })((?{ $x = 12; $^R + 17 })[xy])?/;
466 print "not " unless $^R eq '79' and $x eq '12';
470 print "not " unless qr/\b\v$/i eq '(?i-xsm:\bv$)';
474 print "not " unless qr/\b\v$/s eq '(?s-xim:\bv$)';
478 print "not " unless qr/\b\v$/m eq '(?m-xis:\bv$)';
482 print "not " unless qr/\b\v$/x eq '(?x-ism:\bv$)';
486 print "not " unless qr/\b\v$/xism eq '(?msix:\bv$)';
490 print "not " unless qr/\b\v$/ eq '(?-xism:\bv$)';
495 foreach $ans ('', 'c') {
496 /(?<=(?=a)..)((?=c)|.)/g;
497 print "# \$1 ='$1'\n# \$ans='$ans'\nnot " unless $1 eq $ans;
503 foreach $ans ('', 'a', '') {
505 print "# \$& ='$&'\n# \$ans='$ans'\nnot " unless $& eq $ans;
511 my($v,$a,$b,$res) = @_;
513 print "not " unless $res eq $v;
517 prefixify('/a/b/lib/arch', "/a/b/lib", 'X/lib', 'X/lib/arch');
518 prefixify('/a/b/man/arch', "/a/b/man", 'X/man', 'X/man/arch');
522 print "not " unless $1 and /$1/;
529 print "not " unless $b eq '9';
535 print "not " unless $b eq '11';
542 print "not " unless $b eq '14';
550 my $lex_res = ($lex_b =~ qr/$lex_b(?{ $lex_c = $lex_a++ })/);
551 print "not " unless $lex_res eq '1';
554 print "not " unless $lex_a eq '44';
557 print "not " unless $lex_c eq '43';
563 $match = eval { /$a$c$a/ };
565 unless $b eq '14' and $@ =~ /Eval-group not allowed/ and not $match;
575 my $lex_res = ($lex_b =~ qr/17(?{ $lex_c = $lex_a++ })/);
576 print "not " unless $lex_res eq '1';
579 print "not " unless $lex_a eq '44';
582 print "not " unless $lex_c eq '43';
591 '' =~ /(?{ $c = 4 })/;
592 print "not " unless $c == 4;
596 print "not " unless $c == 3;
601 my $warn_pat = shift;
602 return sub { print "not " unless $_[0] =~ /$warn_pat/ }
606 my ($warn_pat, $code) = @_;
608 eval 'BEGIN { use warnings; $SIG{__WARN__} = $warn_pat };' . $code;
615 my $warn_pat = shift;
616 return sub { must_warn(must_warn_pat($warn_pat)) }
619 my $for_future = make_must_warn('reserved for future extensions');
621 &$for_future('q(a:[b]:) =~ /[x[:foo:]]/');
623 #&$for_future('q(a=[b]=) =~ /[x[=foo=]]/');
624 print "ok $test\n"; $test++; # now a fatal croak
626 #&$for_future('q(a.[b].) =~ /[x[.foo.]]/');
627 print "ok $test\n"; $test++; # now a fatal croak
629 # test if failure of patterns returns empty list
652 print "not " if $#+ != 0 or $#- != 0;
656 print "not " if $+[0] != 2 or $-[0] != 1;
661 if defined $+[1] or defined $-[1] or defined $+[2] or defined $-[2];
666 print "not " if $#+ != 2 or $#- != 2;
670 print "not " if $+[0] != 3 or $-[0] != 0;
674 print "not " if $+[1] != 2 or $-[1] != 1;
678 print "not " if $+[2] != 3 or $-[2] != 2;
683 if defined $+[3] or defined $-[3] or defined $+[4] or defined $-[4];
688 print "not " if $#+ != 3 or $#- != 3;
692 print "not " if $+[0] != 3 or $-[0] != 0;
696 print "not " if $+[1] != 2 or $-[1] != 1;
700 print "not " if $+[3] != 3 or $-[3] != 2;
705 if defined $+[2] or defined $-[2] or defined $+[4] or defined $-[4];
710 print "not " if $#+ != 1 or $#- != 1;
714 print "not " if $+[0] != 2 or $-[0] != 0;
718 print "not " if $+[1] != 2 or $-[1] != 1;
723 if defined $+[2] or defined $-[2] or defined $+[3] or defined $-[3];
727 eval { $+[0] = 13; };
729 if $@ !~ /^Modification of a read-only value attempted/;
733 eval { $-[0] = 13; };
735 if $@ !~ /^Modification of a read-only value attempted/;
739 eval { @+ = (7, 6, 5); };
741 if $@ !~ /^Modification of a read-only value attempted/;
745 eval { @- = qw(foo bar); };
747 if $@ !~ /^Modification of a read-only value attempted/;
752 print "#$#-..$#+\nnot " if $#+ != 2 or $#- != 1;
759 print "not " unless "@a" eq "a a";
766 print "not " if $str =~ /^\G/;
770 print "not " if $str =~ /^.\G/;
774 print "not " unless $str =~ /^..\G/;
778 print "not " if $str =~ /^...\G/;
782 print "not " unless $str =~ /.\G./ and $& eq 'bc';
786 print "not " unless $str =~ /\G../ and $& eq 'cd';
790 undef $foo; undef $bar;
791 print "#'$str','$foo','$bar'\nnot "
792 unless $str =~ /b(?{$foo = $_; $bar = pos})c/
793 and $foo eq 'abcde' and $bar eq 2;
797 undef $foo; undef $bar;
799 print "#'$str','$foo','$bar'\nnot "
800 unless $str =~ /b(?{$foo = $_; $bar = pos})c/g
801 and $foo eq 'abcde' and $bar eq 2 and pos $str eq 3;
807 undef $foo; undef $bar;
808 print "#'$str','$foo','$bar'\nnot "
809 unless /b(?{$foo = $_; $bar = pos})c/
810 and $foo eq 'abcde' and $bar eq 2;
814 undef $foo; undef $bar;
815 print "#'$str','$foo','$bar'\nnot "
816 unless /b(?{$foo = $_; $bar = pos})c/g
817 and $foo eq 'abcde' and $bar eq 2 and pos eq 3;
821 undef $foo; undef $bar;
823 1 while /b(?{$foo = $_; $bar = pos})c/g;
824 print "#'$str','$foo','$bar'\nnot "
825 unless $foo eq 'abcde' and $bar eq 2 and not defined pos;
829 undef $foo; undef $bar;
831 print "#'$str','$foo','$bar','$_'\nnot "
832 unless s/b(?{$foo = $_; $bar = pos})c/x/g and $foo eq 'abcde|abcde'
833 and $bar eq 8 and $_ eq 'axde|axde';
840 @dummy = /([ace]).(?{push @res, $1,$2})([ce])(?{push @res, $1,$2})/g;
841 @res = map {defined $_ ? "'$_'" : 'undef'} @res;
843 print "#'@res' '$_'\nnot "
844 unless "@res" eq "'a' undef 'a' 'c' 'e' undef 'a' undef 'a' 'c'";
849 @dummy = /([ace]).(?{push @res, $`,$&,$'})([ce])(?{push @res, $`,$&,$'})/g;
850 @res = map {defined $_ ? "'$_'" : 'undef'} @res;
852 print "#'@res' '$_'\nnot "
854 "'' 'ab' 'cde|abcde' " .
855 "'' 'abc' 'de|abcde' " .
856 "'abcd' 'e|' 'abcde' " .
857 "'abcde|' 'ab' 'cde' " .
858 "'abcde|' 'abc' 'de'" ;
862 #Some more \G anchor checks
863 $foo='aabbccddeeffgg';
868 print "not " unless($1 eq 'ab');
874 print "not " unless($1 eq 'cc');
880 print "not " unless($1 eq 'de');
884 print "not " unless $foo =~ /\Gef/g;
891 print "not " unless($1 eq 'aa');
896 print "not " unless($1 eq 'bb');
902 print "not " unless($1 eq 'cd');
908 print "not " unless('123||x|123|' eq join '|', @res);
912 # see if matching against temporaries (created via pp_helem()) is safe
913 { foo => "ok $test\n".$^X }->{foo} =~ /^(.*)\n/g;
917 # See if $i work inside (?{}) in the presense of saved substrings and
921 s/(\w)(?{push @b, $1})/,$1,/g for @a;
923 print "# \@b='@b', expect 'f o o b a r'\nnot " unless("@b" eq "f o o b a r");
927 print "not " unless("@a" eq ",f,,o,,o, ,b,,a,,r,");
932 { (?> [^{}]+ | (??{ $brackets }) )* }
936 print "ok $test\n"; # Did we survive?
939 "something { long { and } hairy" =~ $brackets;
940 print "ok $test\n"; # Did we survive?
943 "something { long { and } hairy" =~ m/((??{ $brackets }))/;
944 print "not " unless $1 eq "{ and }";
950 m/^-.*bb/mg and print "not ";
956 $text =~ /\GXb*X/g and print 'not ';
960 $text = "xA\n" x 500;
961 $text =~ /^\s*A/m and print 'not ';
966 @res = ($text =~ /.*?(b).*?\b/g);
967 "@res" eq 'b b' or print 'not ';
974 @c = grep(/[^\s]/,@a);
975 print "not " if "@b" ne "@c";
980 @c = grep(/[\S]/,@a);
981 print "not " if "@b" ne "@c";
986 @c = grep(/[^\S]/,@a);
987 print "not " if "@b" ne "@c";
992 @c = grep(/[\s]/,@a);
993 print "not " if "@b" ne "@c";
998 @c = grep(/[^\d]/,@a);
999 print "not " if "@b" ne "@c";
1004 @c = grep(/[\D]/,@a);
1005 print "not " if "@b" ne "@c";
1010 @c = grep(/[^\D]/,@a);
1011 print "not " if "@b" ne "@c";
1016 @c = grep(/[\d]/,@a);
1017 print "not " if "@b" ne "@c";
1022 @c = grep(/[^\w]/,@a);
1023 print "not " if "@b" ne "@c";
1028 @c = grep(/[\W]/,@a);
1029 print "not " if "@b" ne "@c";
1034 @c = grep(/[^\W]/,@a);
1035 print "not " if "@b" ne "@c";
1040 @c = grep(/[\w]/,@a);
1041 print "not " if "@b" ne "@c";
1045 # see if backtracking optimization works correctly
1046 "\n\n" =~ /\n $ \n/x or print "not ";
1050 "\n\n" =~ /\n* $ \n/x or print "not ";
1054 "\n\n" =~ /\n+ $ \n/x or print "not ";
1058 [] =~ /^ARRAY/ or print "# [] \nnot ";
1065 use overload '""' => sub { 'Object S' };
1066 sub new { bless [] }
1071 $a and $a =~ /^Object\sS/ or print "# '$a' \nnot ";
1075 # test result of match used as match (!)
1076 'a1b' =~ ('xyz' =~ /y/) and $` eq 'a' or print "not ";
1080 'a1b' =~ ('xyz' =~ /t/) and $` eq 'a' or print "not ";
1086 local $SIG{__WARN__} = sub { $w = 1 };
1088 $w = 1 if ("1\n" x 102) =~ /^\s*\n/m;
1090 print $w ? "not " : "", "ok $test\n";
1093 my %space = ( spc => " ",
1098 # There's no \v but the vertical tabulator seems miraculously
1099 # be 11 both in ASCII and EBCDIC.
1103 my @space0 = sort grep { $space{$_} =~ /\s/ } keys %space;
1104 my @space1 = sort grep { $space{$_} =~ /[[:space:]]/ } keys %space;
1105 my @space2 = sort grep { $space{$_} =~ /[[:blank:]]/ } keys %space;
1107 print "not " unless "@space0" eq "cr ff lf spc tab";
1108 print "ok $test # @space0\n";
1111 print "not " unless "@space1" eq "cr ff lf spc tab vt";
1112 print "ok $test # @space1\n";
1115 print "not " unless "@space2" eq "spc tab";
1116 print "ok $test # @space2\n";
1119 # bugid 20001021.005 - this caused a SEGV
1120 print "not " unless undef =~ /^([^\/]*)(.*)$/;
1124 # bugid 20000731.001
1126 print "not " unless "A \x{263a} B z C" =~ /A . B (??{ "z" }) C/;
1130 my $ordA = ord('A');
1133 if (/(.)(\C)(\C)(.)/) {
1138 print "not ok 233\n";
1140 if ($ordA == 65) { # ASCII (or equivalent), should be UTF-8
1144 print "not ok 234\n";
1149 print "not ok 235\n";
1151 } elsif ($ordA == 193) { # EBCDIC (or equivalent), should be UTF-EBCDIC
1155 print "not ok 234\n";
1160 print "not ok 235\n";
1164 print "not ok $_ # ord('A') == $ordA\n";
1170 print "not ok 236\n";
1174 print "not ok $_\n";
1180 # currently \C are still tagged as UTF-8
1185 print "not ok 238\n";
1187 } elsif ($ordA == 193) {
1191 print "not ok 238\n";
1194 print "not ok 238 # ord('A') == $ordA\n";
1198 print "not ok $_\n";
1203 # currently \C are still tagged as UTF-8
1208 print "not ok 240\n";
1210 } elsif ($ordA == 193) {
1214 print "not ok 240\n";
1217 print "not ok 240 # ord('A') == $ordA\n";
1221 print "not ok $_\n";
1226 # japhy -- added 03/03/2001
1227 () = (my $str = "abc") =~ /(...)/;
1229 print "not " if $1 ne "abc";
1233 # The 242 and 243 go with the 244 and 245.
1234 # The trick is that in EBCDIC the explicit numeric range should match
1235 # (as also in non-EBCDIC) but the explicit alphabetic range should not match.
1237 if ("\x8e" =~ /[\x89-\x91]/) {
1240 print "not ok 242\n";
1243 if ("\xce" =~ /[\xc9-\xd1]/) {
1246 print "not ok 243\n";
1249 # In most places these tests would succeed since \x8e does not
1250 # in most character sets match 'i' or 'j' nor would \xce match
1251 # 'I' or 'J', but strictly speaking these tests are here for
1252 # the good of EBCDIC, so let's test these only there.
1253 if (ord('i') == 0x89 && ord('J') == 0xd1) { # EBCDIC
1254 if ("\x8e" !~ /[i-j]/) {
1257 print "not ok 244\n";
1259 if ("\xce" !~ /[I-J]/) {
1262 print "not ok 245\n";
1266 print "ok $_ # Skip: only in EBCDIC\n";
1270 print "not " unless "\x{ab}" =~ /\x{ab}/;
1273 print "not " unless "\x{abcd}" =~ /\x{abcd}/;
1277 # bug id 20001008.001
1280 my @x = ("stra\337e 138","stra\337e 138");
1282 s/(\d+)\s*([\w\-]+)/$1 . uc $2/e;
1283 my($latin) = /^(.+)(?:\s+\d)/;
1284 print $latin eq "stra\337e" ? "ok $test\n" : # 248,249
1285 "#latin[$latin]\nnot ok $test\n";
1287 $latin =~ s/stra\337e/straße/; # \303\237 after the 2nd a
1288 use utf8; # needed for the raw UTF-8
1289 $latin =~ s!(s)tr(?:aß|s+e)!$1tr.!; # \303\237 after the a
1294 print "not " unless "ba\xd4c" =~ /([a\xd4]+)/ && $1 eq "a\xd4";
1297 print "not " unless "ba\xd4c" =~ /([a\xd4]+)/ && $1 eq "a\x{d4}";
1300 print "not " unless "ba\x{d4}c" =~ /([a\xd4]+)/ && $1 eq "a\x{d4}";
1303 print "not " unless "ba\x{d4}c" =~ /([a\xd4]+)/ && $1 eq "a\xd4";
1306 print "not " unless "ba\xd4c" =~ /([a\x{d4}]+)/ && $1 eq "a\xd4";
1309 print "not " unless "ba\xd4c" =~ /([a\x{d4}]+)/ && $1 eq "a\x{d4}";
1312 print "not " unless "ba\x{d4}c" =~ /([a\x{d4}]+)/ && $1 eq "a\x{d4}";
1315 print "not " unless "ba\x{d4}c" =~ /([a\x{d4}]+)/ && $1 eq "a\xd4";
1320 # the first half of 20001028.003
1323 my ($Y) = $X =~ /(.*)/;
1324 print "not " unless $Y eq v1448 && length($Y) == 1;
1331 my $X = "Szab\x{f3},Bal\x{e1}zs";
1333 $Y =~ s/(B)/$1/ for 0..3;
1334 print "not " unless $Y eq $X && $X eq "Szab\x{f3},Bal\x{e1}zs";
1339 # the second half of 20001028.003
1342 $X =~ s/^/chr(1488)/e;
1343 print "not " unless length $X == 1 && ord($X) == 1488;
1354 print "not " unless $x eq "\x{100}B" && length($x) == 2;
1359 # bug id 20001230.002
1361 print "not " unless "École" =~ /^\C\C(.)/ && $1 eq 'c';
1364 print "not " unless "École" =~ /^\C\C(c)/;
1369 my $test = 264; # till 575
1371 use charnames ":full";
1373 # This is far from complete testing, there are dozens of character
1374 # classes in Unicode. The mixing of literals and \N{...} is
1375 # intentional so that in non-Latin-1 places we test the native
1376 # characters, not the Unicode code points.
1380 "\N{CYRILLIC SMALL LETTER A}" => 'Ll',
1382 "\N{GREEK CAPITAL LETTER ALPHA}" => 'Lu',
1383 "\N{HIRAGANA LETTER SMALL A}" => 'Lo',
1384 "\N{COMBINING GRAVE ACCENT}" => 'Mn',
1386 "\N{ARABIC-INDIC DIGIT ZERO}" => 'Nd',
1393 for my $char (map { s/^\S+ //; $_ }
1394 sort map { sprintf("%06x", ord($_))." $_" } keys %s) {
1395 my $class = $s{$char};
1396 my $code = sprintf("%06x", ord($char));
1397 printf "#\n# 0x$code\n#\n";
1398 print "# IsAlpha\n";
1399 if ($class =~ /^[LM]/) {
1400 print "not " unless $char =~ /\p{IsAlpha}/;
1401 print "ok $test\n"; $test++;
1402 print "not " if $char =~ /\P{IsAlpha}/;
1403 print "ok $test\n"; $test++;
1405 print "not " if $char =~ /\p{IsAlpha}/;
1406 print "ok $test\n"; $test++;
1407 print "not " unless $char =~ /\P{IsAlpha}/;
1408 print "ok $test\n"; $test++;
1410 print "# IsAlnum\n";
1411 if ($class =~ /^[LMN]/ && $char ne "_") {
1412 print "not " unless $char =~ /\p{IsAlnum}/;
1413 print "ok $test\n"; $test++;
1414 print "not " if $char =~ /\P{IsAlnum}/;
1415 print "ok $test\n"; $test++;
1417 print "not " if $char =~ /\p{IsAlnum}/;
1418 print "ok $test\n"; $test++;
1419 print "not " unless $char =~ /\P{IsAlnum}/;
1420 print "ok $test\n"; $test++;
1422 print "# IsASCII\n";
1423 if (ord("A") == 193) {
1424 print "ok $test # Skip: in EBCDIC\n"; $test++;
1425 print "ok $test # Skip: in EBCDIC\n"; $test++;
1427 if ($code le '00007f') {
1428 print "not " unless $char =~ /\p{IsASCII}/;
1429 print "ok $test\n"; $test++;
1430 print "not " if $char =~ /\P{IsASCII}/;
1431 print "ok $test\n"; $test++;
1433 print "not " if $char =~ /\p{IsASCII}/;
1434 print "ok $test\n"; $test++;
1435 print "not " unless $char =~ /\P{IsASCII}/;
1436 print "ok $test\n"; $test++;
1439 print "# IsCntrl\n";
1440 if ($class =~ /^C/) {
1441 print "not " unless $char =~ /\p{IsCntrl}/;
1442 print "ok $test\n"; $test++;
1443 print "not " if $char =~ /\P{IsCntrl}/;
1444 print "ok $test\n"; $test++;
1446 print "not " if $char =~ /\p{IsCntrl}/;
1447 print "ok $test\n"; $test++;
1448 print "not " unless $char =~ /\P{IsCntrl}/;
1449 print "ok $test\n"; $test++;
1451 print "# IsBlank\n";
1452 if ($class =~ /^Z[lp]/ || $char eq " ") {
1453 print "not " unless $char =~ /\p{IsBlank}/;
1454 print "ok $test\n"; $test++;
1455 print "not " if $char =~ /\P{IsBlank}/;
1456 print "ok $test\n"; $test++;
1458 print "not " if $char =~ /\p{IsBlank}/;
1459 print "ok $test\n"; $test++;
1460 print "not " unless $char =~ /\P{IsBlank}/;
1461 print "ok $test\n"; $test++;
1463 print "# IsDigit\n";
1464 if ($class =~ /^Nd$/) {
1465 print "not " unless $char =~ /\p{IsDigit}/;
1466 print "ok $test\n"; $test++;
1467 print "not " if $char =~ /\P{IsDigit}/;
1468 print "ok $test\n"; $test++;
1470 print "not " if $char =~ /\p{IsDigit}/;
1471 print "ok $test\n"; $test++;
1472 print "not " unless $char =~ /\P{IsDigit}/;
1473 print "ok $test\n"; $test++;
1475 print "# IsGraph\n";
1476 if ($class =~ /^([LMNPS])|Co/) {
1477 print "not " unless $char =~ /\p{IsGraph}/;
1478 print "ok $test\n"; $test++;
1479 print "not " if $char =~ /\P{IsGraph}/;
1480 print "ok $test\n"; $test++;
1482 print "not " if $char =~ /\p{IsGraph}/;
1483 print "ok $test\n"; $test++;
1484 print "not " unless $char =~ /\P{IsGraph}/;
1485 print "ok $test\n"; $test++;
1487 print "# IsLower\n";
1488 if ($class =~ /^Ll$/) {
1489 print "not " unless $char =~ /\p{IsLower}/;
1490 print "ok $test\n"; $test++;
1491 print "not " if $char =~ /\P{IsLower}/;
1492 print "ok $test\n"; $test++;
1494 print "not " if $char =~ /\p{IsLower}/;
1495 print "ok $test\n"; $test++;
1496 print "not " unless $char =~ /\P{IsLower}/;
1497 print "ok $test\n"; $test++;
1499 print "# IsPrint\n";
1500 if ($class =~ /^([LMNPS])|Co|Zs/) {
1501 print "not " unless $char =~ /\p{IsPrint}/;
1502 print "ok $test\n"; $test++;
1503 print "not " if $char =~ /\P{IsPrint}/;
1504 print "ok $test\n"; $test++;
1506 print "not " if $char =~ /\p{IsPrint}/;
1507 print "ok $test\n"; $test++;
1508 print "not " unless $char =~ /\P{IsPrint}/;
1509 print "ok $test\n"; $test++;
1511 print "# IsPunct\n";
1512 if ($class =~ /^P/ || $char eq "_") {
1513 print "not " unless $char =~ /\p{IsPunct}/;
1514 print "ok $test\n"; $test++;
1515 print "not " if $char =~ /\P{IsPunct}/;
1516 print "ok $test\n"; $test++;
1518 print "not " if $char =~ /\p{IsPunct}/;
1519 print "ok $test\n"; $test++;
1520 print "not " unless $char =~ /\P{IsPunct}/;
1521 print "ok $test\n"; $test++;
1523 print "# IsSpace\n";
1524 if ($class =~ /^Z/ || ($code =~ /^(0009|000A|000B|000C|000D)$/)) {
1525 print "not " unless $char =~ /\p{IsSpace}/;
1526 print "ok $test\n"; $test++;
1527 print "not " if $char =~ /\P{IsSpace}/;
1528 print "ok $test\n"; $test++;
1530 print "not " if $char =~ /\p{IsSpace}/;
1531 print "ok $test\n"; $test++;
1532 print "not " unless $char =~ /\P{IsSpace}/;
1533 print "ok $test\n"; $test++;
1535 print "# IsUpper\n";
1536 if ($class =~ /^L[ut]/) {
1537 print "not " unless $char =~ /\p{IsUpper}/;
1538 print "ok $test\n"; $test++;
1539 print "not " if $char =~ /\P{IsUpper}/;
1540 print "ok $test\n"; $test++;
1542 print "not " if $char =~ /\p{IsUpper}/;
1543 print "ok $test\n"; $test++;
1544 print "not " unless $char =~ /\P{IsUpper}/;
1545 print "ok $test\n"; $test++;
1548 if ($class =~ /^[LMN]/ || $char eq "_") {
1549 print "not " unless $char =~ /\p{IsWord}/;
1550 print "ok $test\n"; $test++;
1551 print "not " if $char =~ /\P{IsWord}/;
1552 print "ok $test\n"; $test++;
1554 print "not " if $char =~ /\p{IsWord}/;
1555 print "ok $test\n"; $test++;
1556 print "not " unless $char =~ /\P{IsWord}/;
1557 print "ok $test\n"; $test++;
1563 $_ = "abc\x{100}\x{200}\x{300}\x{380}\x{400}defg";
1565 if (/(.\x{300})./) {
1568 print "not " unless $` eq "abc\x{100}" && length($`) == 4;
1571 print "not " unless $& eq "\x{200}\x{300}\x{380}" && length($&) == 3;
1574 print "not " unless $' eq "\x{400}defg" && length($') == 5;
1577 print "not " unless $1 eq "\x{200}\x{300}" && length($1) == 2;
1580 for (576..580) { print "not ok $_\n" }
1585 # bug id 20010306.008
1588 # The original bug report had 'no utf8' here but that was irrelevant.
1589 $a =~ m/\w/; # used to core dump
1597 # bugid 20010410.006
1599 '/(.*?)\{(.*?)\}/csg',
1600 '/(.*?)\{(.*?)\}/cg',
1601 '/(.*?)\{(.*?)\}/sg',
1602 '/(.*?)\{(.*?)\}/g',
1603 '/(.+?)\{(.+?)\}/csg',
1609 $input = "a{b}c{d}";
1611 while (eval \$input =~ $rx) {
1612 print "# \\\$1 = '\$1' \\\$2 = '\$2'\n";
1616 print "not " unless $i == 2;
1617 print "ok " . $test++ . "\n";
1622 # from Robin Houston
1624 my $x = "\x{10FFFD}";
1626 print "not " unless ord($x) == 0x10FFFD && length($x) == 1;
1633 print "not " if $x =~ /[\x80-\xff]/;
1636 print "not " if $x =~ /[\x80-\x{100}]/;
1639 print "not " if $x =~ /[\x{100}]/;
1642 print "not " if $x =~ /\p{InLatin1Supplement}/;
1645 print "not " unless $x =~ /\P{InLatin1Supplement}/;
1648 print "not " if $x =~ /\p{InLatinExtendedA}/;
1651 print "not " unless $x =~ /\P{InLatinExtendedA}/;
1658 print "not " unless $x =~ /[\x80-\xff]/;
1661 print "not " unless $x =~ /[\x80-\x{100}]/;
1664 print "not " if $x =~ /[\x{100}]/;
1667 print "not " unless $x =~ /\p{InLatin1Supplement}/;
1670 print "not " if $x =~ /\P{InLatin1Supplement}/;
1673 print "not " if $x =~ /\p{InLatinExtendedA}/;
1676 print "not " unless $x =~ /\P{InLatinExtendedA}/;
1683 print "not " unless $x =~ /[\x80-\xff]/;
1686 print "not " unless $x =~ /[\x80-\x{100}]/;
1689 print "not " if $x =~ /[\x{100}]/;
1692 # the next two tests must be ignored on EBCDIC
1693 print "not " unless $x =~ /\p{InLatin1Supplement}/ or ord("A") == 193;
1696 print "not " if $x =~ /\P{InLatin1Supplement}/ and ord("A") != 193;
1699 print "not " if $x =~ /\p{InLatinExtendedA}/;
1702 print "not " unless $x =~ /\P{InLatinExtendedA}/;
1709 print "not " if $x =~ /[\x80-\xff]/;
1712 print "not " unless $x =~ /[\x80-\x{100}]/;
1715 print "not " unless $x =~ /[\x{100}]/;
1718 print "not " if $x =~ /\p{InLatin1Supplement}/;
1721 print "not " unless $x =~ /\P{InLatin1Supplement}/;
1724 print "not " unless $x =~ /\p{InLatinExtendedA}/;
1727 print "not " if $x =~ /\P{InLatinExtendedA}/;
1735 local $SIG{__WARN__} = sub { $w .= shift };
1739 print "not " if $w !~ /^Useless \(\?c\)/;
1744 print "not " if $w !~ /^Useless \(\?-c\)/;
1749 print "not " if $w !~ /^Useless \(\?g\)/;
1754 print "not " if $w !~ /^Useless \(\?-g\)/;
1759 print "not " if $w !~ /^Useless \(\?o\)/;
1764 print "not " if $w !~ /^Useless \(\?-o\)/;
1767 # now test multi-error regexes
1771 print "not " if $w !~ /^Useless \(\?g\).*\nUseless \(\?-o\)/;
1776 print "not " if $w !~ /^Useless \(\?g\).*\nUseless \(\?-c\)/;
1780 eval 'qr/(?o-cg)/'; # (?c) means (?g) error won't be thrown
1781 print "not " if $w !~ /^Useless \(\?o\).*\nUseless \(\?-c\)/;
1786 print "not " if $w !~ /^Useless \(\?o\).*\nUseless \(\?g\).*\nUseless \(\?c\)/;
1790 # More Unicode "class" tests
1793 use charnames ':full';
1795 print "not " unless "\N{LATIN CAPITAL LETTER A}" =~ /\p{InBasicLatin}/;
1798 print "not " unless "\N{LATIN CAPITAL LETTER A WITH GRAVE}" =~ /\p{InLatin1Supplement}/;
1801 print "not " unless "\N{LATIN CAPITAL LETTER A WITH MACRON}" =~ /\p{InLatinExtendedA}/;
1804 print "not " unless "\N{LATIN SMALL LETTER B WITH STROKE}" =~ /\p{InLatinExtendedB}/;
1807 print "not " unless "\N{KATAKANA LETTER SMALL A}" =~ /\p{InKatakana}/;
1813 eval <<"EOT"; die if $@;
1818 /x && print "ok 631\n";
1821 eval <<"EOT"; die if $@;
1826 /x && print "ok 632\n";
1830 sub test_o { $_[0] =~/$_[1]/o; return $1}
1831 if(test_o('abc','(.)..') eq 'a') {
1834 print "not ok 633\n";
1836 if(test_o('abc','..(.)') eq 'a') {
1839 print "not ok 634\n";
1842 # 635..639: ID 20010619.003 (only the space character is
1843 # supposed to be [:print:], not the whole isprint()).
1845 print "not " if "\n" =~ /[[:print:]]/;
1848 print "not " if "\t" =~ /[[:print:]]/;
1851 # Amazingly vertical tabulator is the same in ASCII and EBCDIC.
1852 print "not " if "\014" =~ /[[:print:]]/;
1855 print "not " if "\r" =~ /[[:print:]]/;
1858 print "not " unless " " =~ /[[:print:]]/;
1862 ## Test basic $^N usage outside of a regex
1865 $T="ok 640\n";if ($x =~ /cde/ and not defined $^N) {print $T} else {print "not $T"};
1866 $T="ok 641\n";if ($x =~ /(cde)/ and $^N eq "cde") {print $T} else {print "not $T"};
1867 $T="ok 642\n";if ($x =~ /(c)(d)(e)/ and $^N eq "e") {print $T} else {print "not $T"};
1868 $T="ok 643\n";if ($x =~ /(c(d)e)/ and $^N eq "cde") {print $T} else {print "not $T"};
1869 $T="ok 644\n";if ($x =~ /(foo)|(c(d)e)/ and $^N eq "cde") {print $T} else {print "not $T"};
1870 $T="ok 645\n";if ($x =~ /(c(d)e)|(foo)/ and $^N eq "cde") {print $T} else {print "not $T"};
1871 $T="ok 646\n";if ($x =~ /(c(d)e)|(abc)/ and $^N eq "abc") {print $T} else {print "not $T"};
1872 $T="ok 647\n";if ($x =~ /(c(d)e)|(abc)x/ and $^N eq "cde") {print $T} else {print "not $T"};
1873 $T="ok 648\n";if ($x =~ /(c(d)e)(abc)?/ and $^N eq "cde") {print $T} else {print "not $T"};
1874 $T="ok 649\n";if ($x =~ /(?:c(d)e)/ and $^N eq "d" ) {print $T} else {print "not $T"};
1875 $T="ok 650\n";if ($x =~ /(?:c(d)e)(?:f)/ and $^N eq "d" ) {print $T} else {print "not $T"};
1876 $T="ok 651\n";if ($x =~ /(?:([abc])|([def]))*/ and $^N eq "f" ){print $T} else {print "not $T"};
1877 $T="ok 652\n";if ($x =~ /(?:([ace])|([bdf]))*/ and $^N eq "f" ){print $T} else {print "not $T"};
1878 $T="ok 653\n";if ($x =~ /(([ace])|([bd]))*/ and $^N eq "e" ){print $T} else {print "not $T"};
1880 $T="ok 654\n";if($x =~ /(([ace])|([bdf]))*/ and $^N eq "f" ){print $T} else {print "not $T"};
1882 ## test to see if $^N is automatically localized -- it should now
1883 ## have the value set in test 653
1884 $T="ok 655\n";if ($^N eq "e" ){print $T} else {print "not $T"};
1887 ## Now test inside (?{...})
1889 $T="ok 656\n";if ($x =~ /a([abc])(?{$y=$^N})c/ and $y eq "b" ){print $T} else {print "not $T"};
1890 $T="ok 657\n";if ($x =~ /a([abc]+)(?{$y=$^N})d/ and $y eq "bc"){print $T} else {print "not $T"};
1891 $T="ok 658\n";if ($x =~ /a([abcdefg]+)(?{$y=$^N})d/ and $y eq "bc"){print $T} else {print "not $T"};
1892 $T="ok 659\n";if ($x =~ /(a([abcdefg]+)(?{$y=$^N})d)(?{$z=$^N})e/ and $y eq "bc" and $z eq "abcd")
1893 {print $T} else {print "not $T"};
1894 $T="ok 660\n";if ($x =~ /(a([abcdefg]+)(?{$y=$^N})de)(?{$z=$^N})/ and $y eq "bc" and $z eq "abcde")
1895 {print $T} else {print "not $T"};
1897 # Test the Unicode script classes
1899 print "not " unless chr(0x100) =~ /\p{IsLatin}/; # outside Latin-1
1902 print "not " unless chr(0x212b) =~ /\p{IsLatin}/; # Angstrom sign, very outside
1905 print "not " unless chr(0x5d0) =~ /\p{IsHebrew}/; # inside InHebrew
1908 print "not " unless chr(0xfb4f) =~ /\p{IsHebrew}/; # outside InHebrew
1911 # # singleton (not in a range, this test must be ignored on EBCDIC)
1912 # print "not " unless chr(0xb5) =~ /\p{IsGreek}/ or ord("A") == 193;
1914 print "ok 665 # 0xb5 moved from Greek to Common with Unicode 4.0.1\n";
1916 print "not " unless chr(0x37a) =~ /\p{IsGreek}/; # singleton
1919 print "not " unless chr(0x386) =~ /\p{IsGreek}/; # singleton
1922 print "not " unless chr(0x387) =~ /\P{IsGreek}/; # not there
1925 print "not " unless chr(0x388) =~ /\p{IsGreek}/; # range
1928 print "not " unless chr(0x38a) =~ /\p{IsGreek}/; # range
1931 print "not " unless chr(0x38b) =~ /\P{IsGreek}/; # not there
1934 print "not " unless chr(0x38c) =~ /\p{IsGreek}/; # singleton
1937 if (ord("A") == 65) {
1939 ## Test [:cntrl:]...
1941 ## Should probably put in tests for all the POSIX stuff, but not sure how to
1942 ## guarantee a specific locale......
1944 $AllBytes = join('', map { chr($_) } 0..255);
1945 ($x = $AllBytes) =~ s/[[:cntrl:]]//g;
1946 if ($x ne join('', map { chr($_) } 0x20..0x7E, 0x80..0xFF)) {
1951 ($x = $AllBytes) =~ s/[^[:cntrl:]]//g;
1952 if ($x ne join('', map { chr($_) } 0..0x1F, 0x7F)) { print "not " }
1955 print "ok $_ # Skip: EBCDIC\n" for 673..674;
1958 # With /s modifier UTF8 chars were interpreted as bytes
1960 my $a = "Hello \x{263A} World";
1962 my @a = ($a =~ /./gs);
1964 print "not " unless $#a == 12;
1968 @a = ("foo\nbar" =~ /./g);
1969 print "ok 676\n" if @a == 6 && "@a" eq "f o o b a r";
1971 @a = ("foo\nbar" =~ /./gs);
1972 print "ok 677\n" if @a == 7 && "@a" eq "f o o \n b a r";
1974 @a = ("foo\nbar" =~ /\C/g);
1975 print "ok 678\n" if @a == 7 && "@a" eq "f o o \n b a r";
1977 @a = ("foo\nbar" =~ /\C/gs);
1978 print "ok 679\n" if @a == 7 && "@a" eq "f o o \n b a r";
1980 @a = ("foo\n\x{100}bar" =~ /./g);
1981 print "ok 680\n" if @a == 7 && "@a" eq "f o o \x{100} b a r";
1983 @a = ("foo\n\x{100}bar" =~ /./gs);
1984 print "ok 681\n" if @a == 8 && "@a" eq "f o o \n \x{100} b a r";
1986 ($a, $b) = map { chr } ord('A') == 65 ? (0xc4, 0x80) : (0x8c, 0x41);
1988 @a = ("foo\n\x{100}bar" =~ /\C/g);
1989 print "ok 682\n" if @a == 9 && "@a" eq "f o o \n $a $b b a r";
1991 @a = ("foo\n\x{100}bar" =~ /\C/gs);
1992 print "ok 683\n" if @a == 9 && "@a" eq "f o o \n $a $b b a r";
1995 # [ID 20010814.004] pos() doesn't work when using =~m// in list context
1997 $a = join ":", /b./gc;
1998 $b = join ":", /a./gc;
2000 print "$a $b $c" eq 'ba:ba ad:ae 10' ? "ok 684\n" : "not ok 684\t# $a $b $c\n";
2004 # [ID 20010407.006] matching utf8 return values from functions does not work
2006 package ID_20010407_006;
2015 $x =~ /(..)/; $y = $1;
2016 print "not " unless length($y) == 2 && $y eq $x;
2019 x =~ /(..)/; $y = $1;
2020 print "not " unless length($y) == 2 && $y eq $x;
2027 # Force scalar context on the patern match
2029 my($ok, $name) = @_;
2031 printf "%sok %d - %s\n", ($ok ? "" : "not "), $test, $name;
2033 printf "# Failed test at line %d\n", (caller)[2] unless $ok;
2040 # Check that \x## works. 5.6.1 and 5.005_03 fail some of these.
2042 ok ($x =~ /^\x4EE$/, "Check only 2 bytes of hex are matched.");
2045 ok ($x =~ /^\x4Ei$/, "Check that invalid hex digit stops it (2)");
2048 ok ($x =~ /^\x4j$/, "Check that invalid hex digit stops it (1)");
2051 ok ($x =~ /^\xk$/, "Check that invalid hex digit stops it (0)");
2054 ok ($x =~ /^\xx$/, "\\xx isn't to be treated as \\0");
2057 ok ($x =~ /^\xxa$/, "\\xxa isn't to be treated as \\xa");
2060 ok ($x =~ /^\x9_b$/, "\\x9_b isn't to be treated as \\x9b");
2062 print "# and now again in [] ranges\n";
2065 ok ($x =~ /^[\x4EE]{2}$/, "Check only 2 bytes of hex are matched.");
2068 ok ($x =~ /^[\x4Ei]{2}$/, "Check that invalid hex digit stops it (2)");
2071 ok ($x =~ /^[\x4j]{2}$/, "Check that invalid hex digit stops it (1)");
2074 ok ($x =~ /^[\xk]{2}$/, "Check that invalid hex digit stops it (0)");
2077 ok ($x =~ /^[\xx]{2}$/, "\\xx isn't to be treated as \\0");
2080 ok ($x =~ /^[\xxa]{3}$/, "\\xxa isn't to be treated as \\xa");
2083 ok ($x =~ /^[\x9_b]{3}$/, "\\x9_b isn't to be treated as \\x9b");
2088 # Check that \x{##} works. 5.6.1 fails quite a few of these.
2091 ok ($x =~ /^\x{9_b}$/, "\\x{9_b} is to be treated as \\x9b");
2094 ok ($x =~ /^\x{9_b}y$/, "\\x{9_b} is to be treated as \\x9b (again)");
2097 ok ($x =~ /^\x{9b_}y$/, "\\x{9b_} is to be treated as \\x9b");
2100 ok ($x =~ /^\x{9_bq}y$/, "\\x{9_bc} is to be treated as \\x9b");
2103 ok ($x =~ /^\x{x9b}y$/, "\\x{x9b} is to be treated as \\x0");
2106 ok ($x =~ /^\x{0x9b}y$/, "\\x{0x9b} is to be treated as \\x0");
2109 ok ($x =~ /^\x{09b}y$/, "\\x{09b} is to be treated as \\x9b");
2111 print "# and now again in [] ranges\n";
2114 ok ($x =~ /^[\x{9_b}]$/, "\\x{9_b} is to be treated as \\x9b");
2117 ok ($x =~ /^[\x{9_b}y]{2}$/, "\\x{9_b} is to be treated as \\x9b (again)");
2120 ok ($x =~ /^[\x{9b_}y]{2}$/, "\\x{9b_} is to be treated as \\x9b");
2123 ok ($x =~ /^[\x{9_bq}y]{2}$/, "\\x{9_bc} is to be treated as \\x9b");
2126 ok ($x =~ /^[\x{x9b}y]{2}$/, "\\x{x9b} is to be treated as \\x0");
2129 ok ($x =~ /^[\x{0x9b}y]{2}$/, "\\x{0x9b} is to be treated as \\x0");
2132 ok ($x =~ /^[\x{09b}y]{2}$/, "\\x{09b} is to be treated as \\x9b");
2136 # high bit bug -- japhy
2138 $x =~ /.*?\200/ or print "not ";
2142 print "# some Unicode properties\n";
2145 # Dashes, underbars, case.
2146 print "not " unless "\x80" =~ /\p{in-latin1_SUPPLEMENT}/;
2149 # Complement, leading and trailing whitespace.
2150 print "not " unless "\x80" =~ /\P{ ^ In Latin 1 Supplement }/;
2153 # No ^In, dashes, case, dash, any intervening (word-break) whitespace.
2154 # (well, newlines don't work...)
2155 print "not " unless "\x80" =~ /\p{latin-1 supplement}/;
2160 print "not " unless "a" =~ /\pL/;
2163 print "not " unless "a" =~ /\p{IsLl}/;
2166 print "not " if "a" =~ /\p{IsLu}/;
2169 print "not " unless "a" =~ /\p{Ll}/;
2172 print "not " if "a" =~ /\p{Lu}/;
2175 print "not " unless "A" =~ /\pL/;
2178 print "not " unless "A" =~ /\p{IsLu}/;
2181 print "not " if "A" =~ /\p{IsLl}/;
2184 print "not " unless "A" =~ /\p{Lu}/;
2187 print "not " if "A" =~ /\p{Ll}/;
2190 print "not " if "a" =~ /\PL/;
2193 print "not " if "a" =~ /\P{IsLl}/;
2196 print "not " unless "a" =~ /\P{IsLu}/;
2199 print "not " if "a" =~ /\P{Ll}/;
2202 print "not " unless "a" =~ /\P{Lu}/;
2205 print "not " if "A" =~ /\PL/;
2208 print "not " if "A" =~ /\P{IsLu}/;
2211 print "not " unless "A" =~ /\P{IsLl}/;
2214 print "not " if "A" =~ /\P{Lu}/;
2217 print "not " unless "A" =~ /\P{Ll}/;
2223 print "not " if "a" =~ /\p{Common}/;
2226 print "not " unless "1" =~ /\p{Common}/;
2231 print "not " if "a" =~ /\p{Inherited}/;
2234 print "not " unless "\x{300}" =~ /\p{Inherited}/;
2239 # L& and LC are the same
2240 print "not " unless "a" =~ /\p{LC}/ and "a" =~ /\p{L&}/;
2243 print "not " if "1" =~ /\p{LC}/ or "1" =~ /\p{L&}/;
2248 print "not " unless "a" =~ /\p{Lowercase Letter}/;
2251 print "not " if "A" =~ /\p{lowercaseletter}/;
2256 print "not " unless "\x{AC00}" =~ /\p{HangulSyllables}/;
2261 # Script=, Block=, Category=
2263 print "not " unless "\x{0100}" =~ /\p{Script=Latin}/;
2266 print "not " unless "\x{0100}" =~ /\p{Block=LatinExtendedA}/;
2269 print "not " unless "\x{0100}" =~ /\p{Category=UppercaseLetter}/;
2274 print "# the basic character classes and Unicode \n";
2276 # 0100;LATIN CAPITAL LETTER A WITH MACRON;Lu;0;L;0041 0304;;;;N;LATIN CAPITAL LETTER A MACRON;;;0101;
2277 print "not " unless "\x{0100}" =~ /\w/;
2280 # 0660;ARABIC-INDIC DIGIT ZERO;Nd;0;AN;;0;0;0;N;;;;;
2281 print "not " unless "\x{0660}" =~ /\d/;
2284 # 1680;OGHAM SPACE MARK;Zs;0;WS;;;;;N;;;;;
2285 print "not " unless "\x{1680}" =~ /\s/;
2290 print "# folding matches and Unicode\n";
2292 print "not " unless "a\x{100}" =~ /A/i;
2295 print "not " unless "A\x{100}" =~ /a/i;
2298 print "not " unless "a\x{100}" =~ /a/i;
2301 print "not " unless "A\x{100}" =~ /A/i;
2304 print "not " unless "\x{101}a" =~ /\x{100}/i;
2307 print "not " unless "\x{100}a" =~ /\x{100}/i;
2310 print "not " unless "\x{101}a" =~ /\x{101}/i;
2313 print "not " unless "\x{100}a" =~ /\x{101}/i;
2316 print "not " unless "a\x{100}" =~ /A\x{100}/i;
2319 print "not " unless "A\x{100}" =~ /a\x{100}/i;
2322 print "not " unless "a\x{100}" =~ /a\x{100}/i;
2325 print "not " unless "A\x{100}" =~ /A\x{100}/i;
2328 print "not " unless "a\x{100}" =~ /[A]/i;
2331 print "not " unless "A\x{100}" =~ /[a]/i;
2334 print "not " unless "a\x{100}" =~ /[a]/i;
2337 print "not " unless "A\x{100}" =~ /[A]/i;
2340 print "not " unless "\x{101}a" =~ /[\x{100}]/i;
2343 print "not " unless "\x{100}a" =~ /[\x{100}]/i;
2346 print "not " unless "\x{101}a" =~ /[\x{101}]/i;
2349 print "not " unless "\x{100}a" =~ /[\x{101}]/i;
2355 use charnames ':full';
2357 print "# LATIN LETTER A WITH GRAVE\n";
2358 my $lower = "\N{LATIN SMALL LETTER A WITH GRAVE}";
2359 my $UPPER = "\N{LATIN CAPITAL LETTER A WITH GRAVE}";
2361 print $lower =~ m/$UPPER/i ? "ok 774\n" : "not ok 774\n";
2362 print $UPPER =~ m/$lower/i ? "ok 775\n" : "not ok 775\n";
2363 print $lower =~ m/[$UPPER]/i ? "ok 776\n" : "not ok 776\n";
2364 print $UPPER =~ m/[$lower]/i ? "ok 777\n" : "not ok 777\n";
2366 print "# GREEK LETTER ALPHA WITH VRACHY\n";
2368 $lower = "\N{GREEK CAPITAL LETTER ALPHA WITH VRACHY}";
2369 $UPPER = "\N{GREEK SMALL LETTER ALPHA WITH VRACHY}";
2371 print $lower =~ m/$UPPER/i ? "ok 778\n" : "not ok 778\n";
2372 print $UPPER =~ m/$lower/i ? "ok 779\n" : "not ok 779\n";
2373 print $lower =~ m/[$UPPER]/i ? "ok 780\n" : "not ok 780\n";
2374 print $UPPER =~ m/[$lower]/i ? "ok 781\n" : "not ok 781\n";
2376 print "# LATIN LETTER Y WITH DIAERESIS\n";
2378 $lower = "\N{LATIN CAPITAL LETTER Y WITH DIAERESIS}";
2379 $UPPER = "\N{LATIN SMALL LETTER Y WITH DIAERESIS}";
2380 print $lower =~ m/$UPPER/i ? "ok 782\n" : "not ok 782\n";
2381 print $UPPER =~ m/$lower/i ? "ok 783\n" : "not ok 783\n";
2382 print $lower =~ m/[$UPPER]/i ? "ok 784\n" : "not ok 784\n";
2383 print $UPPER =~ m/[$lower]/i ? "ok 785\n" : "not ok 785\n";
2388 use charnames ':full';
2390 print "# GREEK CAPITAL LETTER SIGMA vs COMBINING GREEK PERISPOMENI\n";
2392 my $SIGMA = "\N{GREEK CAPITAL LETTER SIGMA}";
2393 my $char = "\N{COMBINING GREEK PERISPOMENI}";
2395 # Before #13843 this was failing by matching falsely.
2396 print "_:$char:_" =~ m/_:$SIGMA:_/i ? "not ok 786\n" : "ok 786\n";
2402 use charnames ':full';
2404 print "a!" =~ /^(\X)!/ && $1 eq "a" ?
2405 "ok 787\n" : "not ok 787 # $1\n";
2406 print "\xDF!" =~ /^(\X)!/ && $1 eq "\xDF" ?
2407 "ok 788\n" : "not ok 788 # $1\n";
2408 print "\x{100}!" =~ /^(\X)!/ && $1 eq "\x{100}" ?
2409 "ok 789\n" : "not ok 789 # $1\n";
2410 print "\x{100}\x{300}!" =~ /^(\X)!/ && $1 eq "\x{100}\x{300}" ?
2411 "ok 790\n" : "not ok 790 # $1\n";
2412 print "\N{LATIN CAPITAL LETTER E}!" =~ /^(\X)!/ &&
2413 $1 eq "\N{LATIN CAPITAL LETTER E}" ?
2414 "ok 791\n" : "not ok 791 # $1\n";
2415 print "\N{LATIN CAPITAL LETTER E}\N{COMBINING GRAVE ACCENT}!" =~
2417 $1 eq "\N{LATIN CAPITAL LETTER E}\N{COMBINING GRAVE ACCENT}" ?
2418 "ok 792\n" : "not ok 792 # $1\n";
2422 print "#\\C and \\X\n";
2424 print "!abc!" =~ /a\Cc/ ? "ok 793\n" : "not ok 793\n";
2425 print "!abc!" =~ /a\Xc/ ? "ok 794\n" : "not ok 794\n";
2429 print "# FINAL SIGMA\n";
2431 my $SIGMA = "\x{03A3}"; # CAPITAL
2432 my $Sigma = "\x{03C2}"; # SMALL FINAL
2433 my $sigma = "\x{03C3}"; # SMALL
2435 print $SIGMA =~ /$SIGMA/i ? "ok 795\n" : "not ok 795\n";
2436 print $SIGMA =~ /$Sigma/i ? "ok 796\n" : "not ok 796\n";
2437 print $SIGMA =~ /$sigma/i ? "ok 797\n" : "not ok 797\n";
2439 print $Sigma =~ /$SIGMA/i ? "ok 798\n" : "not ok 798\n";
2440 print $Sigma =~ /$Sigma/i ? "ok 799\n" : "not ok 799\n";
2441 print $Sigma =~ /$sigma/i ? "ok 800\n" : "not ok 800\n";
2443 print $sigma =~ /$SIGMA/i ? "ok 801\n" : "not ok 801\n";
2444 print $sigma =~ /$Sigma/i ? "ok 802\n" : "not ok 802\n";
2445 print $sigma =~ /$sigma/i ? "ok 803\n" : "not ok 803\n";
2447 print $SIGMA =~ /[$SIGMA]/i ? "ok 804\n" : "not ok 804\n";
2448 print $SIGMA =~ /[$Sigma]/i ? "ok 805\n" : "not ok 805\n";
2449 print $SIGMA =~ /[$sigma]/i ? "ok 806\n" : "not ok 806\n";
2451 print $Sigma =~ /[$SIGMA]/i ? "ok 807\n" : "not ok 807\n";
2452 print $Sigma =~ /[$Sigma]/i ? "ok 808\n" : "not ok 808\n";
2453 print $Sigma =~ /[$sigma]/i ? "ok 809\n" : "not ok 809\n";
2455 print $sigma =~ /[$SIGMA]/i ? "ok 810\n" : "not ok 810\n";
2456 print $sigma =~ /[$Sigma]/i ? "ok 811\n" : "not ok 811\n";
2457 print $sigma =~ /[$sigma]/i ? "ok 812\n" : "not ok 812\n";
2461 print "# parlez-vous?\n";
2463 use charnames ':full';
2465 print "fran\N{LATIN SMALL LETTER C}ais" =~
2468 "ok 813\n" : "not ok 813\n";
2470 print "fran\N{LATIN SMALL LETTER C WITH CEDILLA}ais" =~
2472 $& eq "fran\N{LATIN SMALL LETTER C WITH CEDILLA}ais" ?
2473 "ok 814\n" : "not ok 814\n";
2475 print "fran\N{LATIN SMALL LETTER C}ais" =~
2478 "ok 815\n" : "not ok 815\n";
2480 print "franc\N{COMBINING CEDILLA}ais" =~
2481 /franc\C\Cais/ ? # COMBINING CEDILLA is two bytes when encoded
2482 "ok 816\n" : "not ok 816\n";
2484 print "fran\N{LATIN SMALL LETTER C}ais" =~
2487 "ok 817\n" : "not ok 817\n";
2489 print "fran\N{LATIN SMALL LETTER C WITH CEDILLA}ais" =~
2491 $& eq "fran\N{LATIN SMALL LETTER C WITH CEDILLA}ais" ?
2492 "ok 818\n" : "not ok 818\n";
2494 print "franc\N{COMBINING CEDILLA}ais" =~
2496 $& eq "franc\N{COMBINING CEDILLA}ais" ?
2497 "ok 819\n" : "not ok 819\n";
2499 print "fran\N{LATIN SMALL LETTER C WITH CEDILLA}ais" =~
2500 /fran\N{LATIN SMALL LETTER C WITH CEDILLA}ais/ &&
2501 $& eq "fran\N{LATIN SMALL LETTER C WITH CEDILLA}ais" ?
2502 "ok 820\n" : "not ok 820\n";
2504 print "franc\N{COMBINING CEDILLA}ais" =~
2505 /franc\N{COMBINING CEDILLA}ais/ &&
2506 $& eq "franc\N{COMBINING CEDILLA}ais" ?
2507 "ok 821\n" : "not ok 821\n";
2509 print "fran\N{LATIN SMALL LETTER C}ais" =~
2510 /fran(?:c\N{COMBINING CEDILLA}?|\N{LATIN SMALL LETTER C WITH CEDILLA})ais/ &&
2512 "ok 822\n" : "not ok 822\n";
2514 print "fran\N{LATIN SMALL LETTER C}ais" =~
2515 /fran(?:c\N{COMBINING CEDILLA}?|\N{LATIN SMALL LETTER C WITH CEDILLA})ais/ &&
2517 "ok 823\n" : "not ok 823\n";
2519 print "fran\N{LATIN SMALL LETTER C WITH CEDILLA}ais" =~
2520 /fran(?:c\N{COMBINING CEDILLA}?|\N{LATIN SMALL LETTER C WITH CEDILLA})ais/ &&
2521 $& eq "fran\N{LATIN SMALL LETTER C WITH CEDILLA}ais" ?
2522 "ok 824\n" : "not ok 824\n";
2524 print "franc\N{COMBINING CEDILLA}ais" =~
2525 /fran(?:c\N{COMBINING CEDILLA}?|\N{LATIN SMALL LETTER C WITH CEDILLA})ais/ &&
2526 $& eq "franc\N{COMBINING CEDILLA}ais" ?
2527 "ok 825\n" : "not ok 825\n";
2531 print "# Does lingering (and useless) UTF8 flag mess up /i matching?\n";
2534 my $regex = "ABcde";
2535 my $string = "abcDE\x{100}";
2537 if ($string =~ m/$regex/i) {
2540 print "not ok 826\n";
2545 my $regex = "ABcde\x{100}";
2546 my $string = "abcDE";
2548 if ($string =~ m/$regex/i) {
2551 print "not ok 827\n";
2556 my $regex = "ABcde\x{100}";
2557 my $string = "abcDE\x{100}";
2560 if ($string =~ m/$regex/i) {
2563 print "not ok 828\n";
2569 print "# more SIGMAs\n";
2571 my $SIGMA = "\x{03A3}"; # CAPITAL
2572 my $Sigma = "\x{03C2}"; # SMALL FINAL
2573 my $sigma = "\x{03C3}"; # SMALL
2575 my $S3 = "$SIGMA$Sigma$sigma";
2577 print ":$S3:" =~ /:(($SIGMA)+):/i && $1 eq $S3 && $2 eq $sigma ?
2578 "ok 829\n" : "not ok 829\n";
2579 print ":$S3:" =~ /:(($Sigma)+):/i && $1 eq $S3 && $2 eq $sigma ?
2580 "ok 830\n" : "not ok 830\n";
2581 print ":$S3:" =~ /:(($sigma)+):/i && $1 eq $S3 && $2 eq $sigma ?
2582 "ok 831\n" : "not ok 831\n";
2584 print ":$S3:" =~ /:(([$SIGMA])+):/i && $1 eq $S3 && $2 eq $sigma ?
2585 "ok 832\n" : "not ok 832\n";
2586 print ":$S3:" =~ /:(([$Sigma])+):/i && $1 eq $S3 && $2 eq $sigma ?
2587 "ok 833\n" : "not ok 833\n";
2588 print ":$S3:" =~ /:(([$sigma])+):/i && $1 eq $S3 && $2 eq $sigma ?
2589 "ok 834\n" : "not ok 834\n";
2593 print "# LATIN SMALL LETTER SHARP S\n";
2595 use charnames ':full';
2597 print "\N{LATIN SMALL LETTER SHARP S}" =~
2598 /\N{LATIN SMALL LETTER SHARP S}/ ? "ok 835\n" : "not ok 835\n";
2600 print "\N{LATIN SMALL LETTER SHARP S}" =~
2601 /\N{LATIN SMALL LETTER SHARP S}/i ? "ok 836\n" : "not ok 836\n";
2603 print "\N{LATIN SMALL LETTER SHARP S}" =~
2604 /[\N{LATIN SMALL LETTER SHARP S}]/ ? "ok 837\n" : "not ok 837\n";
2606 print "\N{LATIN SMALL LETTER SHARP S}" =~
2607 /[\N{LATIN SMALL LETTER SHARP S}]/i ? "ok 838\n" : "not ok 838\n";
2610 /\N{LATIN SMALL LETTER SHARP S}/i ? "ok 839\n" : "not ok 839\n";
2613 /\N{LATIN SMALL LETTER SHARP S}/i ? "ok 840\n" : "not ok 840\n";
2616 /[\N{LATIN SMALL LETTER SHARP S}]/i ? "ok 841\n" : "not ok 841\n";
2619 /[\N{LATIN SMALL LETTER SHARP S}]/i ? "ok 842\n" : "not ok 842\n";
2621 print "\N{LATIN SMALL LETTER SHARP S}" =~ /ss/i ?
2622 "ok 843\n" : "not ok 843\n";
2624 print "\N{LATIN SMALL LETTER SHARP S}" =~ /SS/i ?
2625 "ok 844\n" : "not ok 844\n";
2629 print "# more whitespace: U+0085, U+2028, U+2029\n";
2631 # U+0085 needs to be forced to be Unicode, the \x{100} does that.
2632 print "<\x{100}\x{0085}>" =~ /<\x{100}\s>/ ? "ok 845\n" : "not ok 845\n";
2633 print "<\x{2028}>" =~ /<\s>/ ? "ok 846\n" : "not ok 846\n";
2634 print "<\x{2029}>" =~ /<\s>/ ? "ok 847\n" : "not ok 847\n";
2638 print "# . with /s should work on characters, as opposed to bytes\n";
2640 my $s = "\x{e4}\x{100}";
2642 # This is not expected to match: the point is that
2643 # neither should we get "Malformed UTF-8" warnings.
2644 print $s =~ /\G(.+?)\n/gcs ?
2645 "not ok 848\n" : "ok 848\n";
2649 while ($s =~ /\G(.)/gs) {
2653 print join("", @c) eq $s ? "ok 849\n" : "not ok 849\n";
2655 my $t1 = "Q003\n\n\x{e4}\x{f6}\n\nQ004\n\n\x{e7}"; # test only chars < 256
2657 while ($t1 =~ / \G ( .+? ) \n\s+ ( .+? ) ( $ | \n\s+ ) /xgcs) {
2661 my $t2 = $t1 . "\x{100}"; # repeat with a larger char
2663 while ($t2 =~ / \G ( .+? ) \n\s+ ( .+? ) ( $ | \n\s+ ) /xgcs) {
2667 print $r1 eq $r2 ? "ok 850\n" : "not ok 850\n";
2671 print "# Unicode lookbehind\n";
2673 print "A\x{100}B" =~ /(?<=A.)B/ ? "ok 851\n" : "not ok 851\n";
2674 print "A\x{200}\x{300}B" =~ /(?<=A..)B/ ? "ok 852\n" : "not ok 852\n";
2675 print "\x{400}AB" =~ /(?<=\x{400}.)B/ ? "ok 853\n" : "not ok 853\n";
2676 print "\x{500\x{600}}B" =~ /(?<=\x{500}.)B/ ? "ok 854\n" : "not ok 854\n";
2680 print "# UTF-8 hash keys and /\$/\n";
2681 # http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2002-01/msg01327.html
2684 my $v = substr($u,0,1);
2685 my $w = substr($u,1,1);
2686 my %u = ( $u => $u, $v => $v, $w => $w );
2689 my $m1 = /^\w*$/ ? 1 : 0;
2690 my $m2 = $u{$_}=~/^\w*$/ ? 1 : 0;
2691 print $m1 == $m2 ? "ok $i\n" : "not ok $i # $m1 $m2\n";
2697 print "# [ID 20020124.005]\n";
2700 for my $char ("a", "\x{df}", "\x{100}"){
2701 $x = "$char b $char";
2706 print substr($x,0,1) eq substr($x,-1,1) ?
2707 "ok $i\n" : "not ok $i # debug: $x\n";
2713 print "# SEGV in s/// and UTF-8\n";
2714 $s = "s#\x{100}" x 4;
2716 print $s eq "s \x{100}" x 4 ? "ok 861\n" : "not ok 861\n";
2720 print "# UTF-8 bug (maybe alreayd known?)\n";
2724 $u =~ s/./\x{100}/g;
2725 print $u eq "\x{100}\x{100}\x{100}" ? "ok 862\n" : "not ok 862\n";
2728 $u =~ s/[ao]/\x{100}/g;
2729 print $u eq "f\x{100}\x{100}b\x{100}r" ? "ok 863\n" : "not ok 863\n";
2731 $u =~ s/\x{100}/e/g;
2732 print $u eq "feeber" ? "ok 864\n" : "not ok 864\n";
2736 print "# UTF-8 bug with s///\n";
2737 # check utf8/non-utf8 mixtures
2738 # try to force all float/anchored check combinations
2743 "xx.*$c", "x.*$c$c", "$c.*xx", "$c$c.*x", "xx.*(?=$c)", "(?=$c).*xx",
2745 print "xxx" =~ /$re/ ? "not ok $test\n" : "ok $test\n";
2747 print +($subst = "xxx") =~ s/$re// ? "not ok $test\n" : "ok $test\n";
2750 for my $re ("xx.*$c*", "$c*.*xx") {
2751 print "xxx" =~ /$re/ ? "ok $test\n" : "not ok $test\n";
2753 ($subst = "xxx") =~ s/$re//;
2754 print $subst eq '' ? "ok $test\n" : "not ok $test\t# $subst\n";
2757 for my $re ("xxy*", "y*xx") {
2758 print "xx$c" =~ /$re/ ? "ok $test\n" : "not ok $test\n";
2760 ($subst = "xx$c") =~ s/$re//;
2761 print $subst eq $c ? "ok $test\n" : "not ok $test\n";
2763 print "xy$c" =~ /$re/ ? "not ok $test\n" : "ok $test\n";
2765 print +($subst = "xy$c") =~ /$re/ ? "not ok $test\n" : "ok $test\n";
2768 for my $re ("xy$c*z", "x$c*yz") {
2769 print "xyz" =~ /$re/ ? "ok $test\n" : "not ok $test\n";
2771 ($subst = "xyz") =~ s/$re//;
2772 print $subst eq '' ? "ok $test\n" : "not ok $test\n";
2778 print "# qr/.../x\n";
2781 my $R = qr/ A B C # D E/x;
2783 print eval {"ABCDE" =~ $R} ? "ok $test\n" : "not ok $test\n";
2786 print eval {"ABCDE" =~ m/$R/} ? "ok $test\n" : "not ok $test\n";
2789 print eval {"ABCDE" =~ m/($R)/} ? "ok $test\n" : "not ok $test\n";
2794 print "# illegal Unicode properties\n";
2797 print eval { "a" =~ /\pq / } ? "not ok $test\n" : "ok $test\n";
2800 print eval { "a" =~ /\p{qrst} / } ? "not ok $test\n" : "ok $test\n";
2805 print "# [ID 20020412.005] wrong pmop flags checked when empty pattern\n";
2806 # requires reuse of last successful pattern
2814 printf "not ok %s\t# 'match once' %s on %s iteration\n", $test,
2815 $match ? 'succeeded' : 'failed', $_ ? 'second' : 'first';
2820 my $result = join '', $test =~ //g;
2821 if ($result eq $test) {
2824 printf "not ok %s\t# expected '%s', got '%s'\n", $test, $test, $result;
2829 print "# user-defined character properties\n";
2863 print "\x{3040}" =~ /\p{InKana1}/ ? "ok $test\n" : "not ok $test\n"; $test++;
2864 print "\x{303F}" =~ /\P{InKana1}/ ? "ok $test\n" : "not ok $test\n"; $test++;
2866 print "\x{3040}" =~ /\p{InKana2}/ ? "ok $test\n" : "not ok $test\n"; $test++;
2867 print "\x{303F}" =~ /\P{InKana2}/ ? "ok $test\n" : "not ok $test\n"; $test++;
2869 print "\x{3041}" =~ /\p{InKana3}/ ? "ok $test\n" : "not ok $test\n"; $test++;
2870 print "\x{3040}" =~ /\P{InKana3}/ ? "ok $test\n" : "not ok $test\n"; $test++;
2872 print "\x{3040}" =~ /\p{InNotKana}/ ? "ok $test\n" : "not ok $test\n"; $test++;
2873 print "\x{3041}" =~ /\P{InNotKana}/ ? "ok $test\n" : "not ok $test\n"; $test++;
2875 sub InConsonant { # Not EBCDIC-aware.
2886 print "d" =~ /\p{InConsonant}/ ? "ok $test\n" : "not ok $test\n"; $test++;
2887 print "e" =~ /\P{InConsonant}/ ? "ok $test\n" : "not ok $test\n"; $test++;
2890 print "# [ID 20020630.002] utf8 regex only matches 32k\n";
2892 for ([ 'byte', "\x{ff}" ], [ 'utf8', "\x{1ff}" ]) {
2893 my($type, $char) = @$_;
2894 for my $len (32000, 32768, 33000) {
2895 my $s = $char . "f" x $len;
2896 my $r = $s =~ /$char([f]*)/gc;
2897 print $r ? "ok $test\n" : "not ok $test\t# <$type x $len> fail\n";
2899 print +(!$r or pos($s) == $len + 1) ? "ok $test\n"
2900 : "not ok $test\t# <$type x $len> pos @{[ pos($s) ]}\n";
2908 $a = bless qr/foo/, 'Foo';
2909 print(('goodfood' =~ $a ? '' : 'not '),
2910 "ok $test\t# reblessed qr// matches\n");
2913 print(($a eq '(?-xism:foo)' ? '' : 'not '),
2914 "ok $test\t# reblessed qr// stringizes\n");
2918 $z=$y = "\317\276"; # $y is byte representation of $x
2921 print(($x =~ $a ? '' : 'not '), "ok $test - utf8 interpolation in qr//\n");
2924 print(("a$a" =~ $x ? '' : 'not '),
2925 "ok $test - stringifed qr// preserves utf8\n");
2928 print(("a$x" =~ /^a$a\z/ ? '' : 'not '),
2929 "ok $test - interpolated qr// preserves utf8\n");
2932 print(("a$x" =~ /^a(??{$a})\z/ ? '' : 'not '),
2933 "ok $test - postponed interpolation of qr// preserves utf8\n");
2936 print((length(qr/##/x) == 12 ? '' : 'not '),
2937 "ok $test - ## in qr// doesn't corrupt memory [perl #17776]\n");
2942 print(("$x$x" =~ /^$x(??{$x})\z/ ? '' : 'not '),
2943 "ok $test - postponed utf8 string in utf8 re matches utf8\n");
2946 print(("$y$x" =~ /^$y(??{$x})\z/ ? '' : 'not '),
2947 "ok $test - postponed utf8 string in non-utf8 re matches utf8\n");
2950 print(("$y$x" !~ /^$y(??{$y})\z/ ? '' : 'not '),
2951 "ok $test - postponed non-utf8 string in non-utf8 re doesn't match utf8\n");
2954 print(("$x$x" !~ /^$x(??{$y})\z/ ? '' : 'not '),
2955 "ok $test - postponed non-utf8 string in utf8 re doesn't match utf8\n");
2958 print(("$y$y" =~ /^$y(??{$y})\z/ ? '' : 'not '),
2959 "ok $test - postponed non-utf8 string in non-utf8 re matches non-utf8\n");
2962 print(("$x$y" =~ /^$x(??{$y})\z/ ? '' : 'not '),
2963 "ok $test - postponed non-utf8 string in utf8 re matches non-utf8\n");
2965 $y = $z; # reset $y after upgrade
2967 print(("$x$y" !~ /^$x(??{$x})\z/ ? '' : 'not '),
2968 "ok $test - postponed utf8 string in utf8 re doesn't match non-utf8\n");
2970 $y = $z; # reset $y after upgrade
2972 print(("$y$y" !~ /^$y(??{$x})\z/ ? '' : 'not '),
2973 "ok $test - postponed utf8 string in non-utf8 re doesn't match non-utf8\n");
2978 print "# more user-defined character properties\n";
2987 print "\x{0712}" =~ /\p{IsSyriac1}/ ? "ok $test\n" : "not ok $test\n"; $test++;
2988 print "\x{072F}" =~ /\P{IsSyriac1}/ ? "ok $test\n" : "not ok $test\n"; $test++;
2997 print "\x{0712}" =~ /\p{Syriac1}/ ? "ok $test\n" : "not ok $test\n"; $test++;
2998 print "\x{072F}" =~ /\P{Syriac1}/ ? "ok $test\n" : "not ok $test\n"; $test++;
3001 print "# Change #18179\n";
3002 # previously failed with "panic: end_shift
3003 my $s = "\x{100}" x 5;
3004 my $ok = $s =~ /(\x{100}{4})/;
3005 my($ord, $len) = (ord $1, length $1);
3006 print +($ok && $ord == 0x100 && $len == 4)
3007 ? "ok $test\n" : "not ok $test\t# $ok/$ord/$len\n";
3012 print "# [perl #15763]\n";
3015 chop $a; # but leaves the UTF-8 flag
3016 $a .= "y"; # 1 byte before "y"
3018 ok($a =~ /^\C/, 'match one \C on 1-byte UTF-8');
3019 ok($a =~ /^\C{1}/, 'match \C{1}');
3021 ok($a =~ /^\Cy/, 'match \Cy');
3022 ok($a =~ /^\C{1}y/, 'match \C{1}y');
3024 $a = "\x{100}y"; # 2 bytes before "y"
3026 ok($a =~ /^\C/, 'match one \C on 2-byte UTF-8');
3027 ok($a =~ /^\C{1}/, 'match \C{1}');
3028 ok($a =~ /^\C\C/, 'match two \C');
3029 ok($a =~ /^\C{2}/, 'match \C{2}');
3031 ok($a =~ /^\C\C\C/, 'match three \C on 2-byte UTF-8 and a byte');
3032 ok($a =~ /^\C{3}/, 'match \C{3}');
3034 ok($a =~ /^\C\Cy/, 'match two \C');
3035 ok($a =~ /^\C{2}y/, 'match \C{2}');
3037 ok($a !~ /^\C\C\Cy/, q{don't match three \Cy});
3038 ok($a !~ /^\C{2}\Cy/, q{don't match \C{3}y});
3040 $a = "\x{1000}y"; # 3 bytes before "y"
3042 ok($a =~ /^\C/, 'match one \C on three-byte UTF-8');
3043 ok($a =~ /^\C{1}/, 'match \C{1}');
3044 ok($a =~ /^\C\C/, 'match two \C');
3045 ok($a =~ /^\C{2}/, 'match \C{2}');
3046 ok($a =~ /^\C\C\C/, 'match three \C');
3047 ok($a =~ /^\C{3}/, 'match \C{3}');
3049 ok($a =~ /^\C\C\C\C/, 'match four \C on three-byte UTF-8 and a byte');
3050 ok($a =~ /^\C{4}/, 'match \C{4}');
3052 ok($a =~ /^\C\C\Cy/, 'match three \Cy');
3053 ok($a =~ /^\C{3}y/, 'match \C{3}y');
3055 ok($a !~ /^\C\C\C\C\y/, q{don't match four \Cy});
3056 ok($a !~ /^\C{4}y/, q{don't match \C{4}y});
3060 utf8::upgrade($_); chop $_; $\="\n";
3061 ok(/[^\s]+/, "m/[^\s]/ utf8");
3062 ok(/[^\d]+/, "m/[^\d]/ utf8");
3063 ok(($a = $_, $_ =~ s/[^\s]+/./g), "s/[^\s]/ utf8");
3064 ok(($a = $_, $a =~ s/[^\d]+/./g), "s/[^\s]/ utf8");
3066 ok("\x{100}" =~ /\x{100}/, "[perl #15397]");
3067 ok("\x{100}" =~ /(\x{100})/, "[perl #15397]");
3068 ok("\x{100}" =~ /(\x{100}){1}/, "[perl #15397]");
3069 ok("\x{100}\x{100}" =~ /(\x{100}){2}/, "[perl #15397]");
3070 ok("\x{100}\x{100}" =~ /(\x{100})(\x{100})/, "[perl #15397]");
3074 ok(!defined $1, "[perl #7471]");
3078 ok(!defined $1, "[perl #7471]");
3080 $pattern = "^(b+?|a){1,2}c";
3081 ok("bac" =~ /$pattern/ && $1 eq 'a', "[perl #3547]");
3082 ok("bbac" =~ /$pattern/ && $1 eq 'a', "[perl #3547]");
3083 ok("bbbac" =~ /$pattern/ && $1 eq 'a', "[perl #3547]");
3084 ok("bbbbac" =~ /$pattern/ && $1 eq 'a', "[perl #3547]");
3089 ok( $1 eq "\x{100}", '$1 is utf-8 [perl #18232]' );
3091 ok( $1 eq "\x{100}", '$1 is still utf-8' );
3092 ok( $1 ne "\xC4\x80", '$1 is not non-utf-8' );
3097 my $attr = 'Name-1' ;
3099 my $NormalChar = qr/[\p{IsDigit}\p{IsLower}\p{IsUpper}]/;
3100 my $NormalWord = qr/${NormalChar}+?/;
3101 my $PredNameHyphen = qr/^${NormalWord}(\-${NormalWord})*?$/;
3104 ok( $attr =~ $PredNameHyphen, "[perl #19767] original test" );
3110 ok ( "0" =~ /\p{N}+\z/, "[perl #19767] variant test" );
3117 $p++ if /(??{ $p })/
3119 ok ($p == 5, "[perl #20683] (??{ }) returns stale values");
3120 { package P; $a=1; sub TIESCALAR { bless[] } sub FETCH { $a++ } }
3125 ok ( $p == 5, "(??{ }) returns stale values");
3129 # Subject: Odd regexp behavior
3130 # From: Markus Kuhn <Markus.Kuhn@cl.cam.ac.uk>
3131 # Date: Wed, 26 Feb 2003 16:53:12 +0000
3132 # Message-Id: <E18o4nw-0008Ly-00@wisbech.cl.cam.ac.uk>
3133 # To: perl-unicode@perl.org
3135 $x = "\x{2019}\nk"; $x =~ s/(\S)\n(\S)/$1 $2/sg;
3136 ok($x eq "\x{2019} k", "Markus Kuhn 2003-02-26");
3138 $x = "b\nk"; $x =~ s/(\S)\n(\S)/$1 $2/sg;
3139 ok($x eq "b k", "Markus Kuhn 2003-02-26");
3141 ok("\x{2019}" =~ /\S/, "Markus Kuhn 2003-02-26");
3146 ok('-1-3-5-' eq join('', split /((??{$i++}))/, '-1-3-5-'),
3147 "[perl #21411] (??{ .. }) corrupts split's stack");
3148 split /(?{'WOW'})/, 'abc';
3149 ok('a|b|c' eq join ('|', @_),
3150 "[perl #21411] (?{ .. }) version of the above");
3154 split /(?{ split "" })/, "abc";
3155 ok(1,'cache_re & "(?{": it dumps core in 5.6.1 & 5.8.0');
3159 ok("\x{100}\n" =~ /\x{100}\n$/, "UTF8 length cache and fbm_compile");
3164 use overload q/""/ => sub { ${$_[0]}; };
3165 sub new { my ($c, $v) = @_; bless \$v, $c; }
3168 $_ = Str->new("a\x{100}/\x{100}b");
3169 ok(join(":", /\b(.)\x{100}/g) eq "a:/", "re_intuit_start and PL_bostr");
3173 $_ = "code: 'x' { '...' }\n"; study;
3174 my @x; push @x, $& while m/'[^\']*'/gx;
3175 ok(join(":", @x) eq "'x':'...'",
3176 "[perl #17757] Parse::RecDescent triggers infinite loop");
3180 my $re = qq/^([^X]*)X/;
3182 ok("\x{100}X" =~ /$re/, "S_cl_and ANYOF_UNICODE & ANYOF_INVERTED");
3187 ok( "a\nb" !~ /^b/, $_[0] );
3188 ok( "a\nb" =~ /^b/m, "$_[0] - with /m" );
3191 $_ = "x"; s/x/func "in subst"/e;
3192 $_ = "x"; s/x/func "in multiline subst"/em;
3193 #$_ = "x"; /x(?{func "in regexp"})/;
3194 #$_ = "x"; /x(?{func "in multiline regexp"})/m;
3199 ok("abcde" eq "$`", '# TODO #19049 - global match not setting $`');
3201 ok("123\x{100}" =~ /^.*1.*23\x{100}$/, 'uft8 + multiple floating substr');
3203 # LATIN SMALL/CAPITAL LETTER A WITH MACRON
3204 ok(" \x{101}" =~ qr/\x{100}/i,
3205 "<20030808193656.5109.1@llama.ni-s.u-net.com>");
3207 # LATIN SMALL/CAPITAL LETTER A WITH RING BELOW
3208 ok(" \x{1E01}" =~ qr/\x{1E00}/i,
3209 "<20030808193656.5109.1@llama.ni-s.u-net.com>");
3211 # DESERET SMALL/CAPITAL LETTER LONG I
3212 ok(" \x{10428}" =~ qr/\x{10400}/i,
3213 "<20030808193656.5109.1@llama.ni-s.u-net.com>");
3215 # LATIN SMALL/CAPITAL LETTER A WITH RING BELOW + 'X'
3216 ok(" \x{1E01}x" =~ qr/\x{1E00}X/i,
3217 "<20030808193656.5109.1@llama.ni-s.u-net.com>");
3220 # [perl #23769] Unicode regex broken on simple example
3221 # regrepeat() didn't handle UTF-8 EXACT case right.
3223 my $s = "\x{a0}\x{a0}\x{a0}\x{100}"; chop $s;
3225 ok($s =~ /\x{a0}/, "[perl #23769]");
3226 ok($s =~ /\x{a0}+/, "[perl #23769]");
3227 ok($s =~ /\x{a0}\x{a0}/, "[perl #23769]");
3229 ok("aaa\x{100}" =~ /(a+)/, "[perl #23769] easy invariant");
3230 ok($1 eq "aaa", "[perl #23769]");
3232 ok("\xa0\xa0\xa0\x{100}" =~ /(\xa0+)/, "[perl #23769] regrepeat invariant");
3233 ok($1 eq "\xa0\xa0\xa0", "[perl #23769]");
3235 ok("ababab\x{100} " =~ /((?:ab)+)/, "[perl #23769] hard invariant");
3236 ok($1 eq "ababab", "[perl #23769]");
3238 ok("\xa0\xa1\xa0\xa1\xa0\xa1\x{100}" =~ /((?:\xa0\xa1)+)/, "[perl #23769] hard variant");
3239 ok($1 eq "\xa0\xa1\xa0\xa1\xa0\xa1", "[perl #23769]");
3241 ok("aaa\x{100} " =~ /(a+?)/, "[perl #23769] easy invariant");
3242 ok($1 eq "a", "[perl #23769]");
3244 ok("\xa0\xa0\xa0\x{100} " =~ /(\xa0+?)/, "[perl #23769] regrepeat variant");
3245 ok($1 eq "\xa0", "[perl #23769]");
3247 ok("ababab\x{100} " =~ /((?:ab)+?)/, "[perl #23769] hard invariant");
3248 ok($1 eq "ab", "[perl #23769]");
3250 ok("\xa0\xa1\xa0\xa1\xa0\xa1\x{100}" =~ /((?:\xa0\xa1)+?)/, "[perl #23769] hard variant");
3251 ok($1 eq "\xa0\xa1", "[perl #23769]");
3253 ok("\xc4\xc4\xc4" !~ /(\x{100}+)/, "[perl #23769] don't match first byte of utf8 representation");
3254 ok("\xc4\xc4\xc4" !~ /(\x{100}+?)/, "[perl #23769] don't match first byte of utf8 representation");
3258 my $head = 'x' x $_;
3259 for my $tail ('\x{0061}', '\x{1234}') {
3261 eval qq{ "$head$tail" =~ /$head$tail/ },
3262 '\x{...} misparsed in regexp near 127 char EXACT limit'
3267 # perl #25269: panic: pp_match start/end pointers
3269 my($x, $y) = "bca" =~ /^(?=.*(a)).*(bc)/;
3271 }, 'captures can move backwards in string');
3273 # perl #27940: \cA not recognized in character classes
3274 ok("a\cAb" =~ /\cA/, '\cA in pattern');
3275 ok("a\cAb" =~ /[\cA]/, '\cA in character class');
3276 ok("a\cAb" =~ /[\cA-\cB]/, '\cA in character class range');
3277 ok("abc" =~ /[^\cA-\cB]/, '\cA in negated character class range');
3278 ok("a\cBb" =~ /[\cA-\cC]/, '\cB in character class range');
3279 ok("a\cCbc" =~ /[^\cA-\cB]/, '\cC in negated character class range');
3280 ok("a\cAb" =~ /(??{"\cA"})/, '\cA in ??{} pattern');
3282 # perl #28532: optional zero-width match at end of string is ignored
3283 ok(("abc" =~ /^abc(\z)?/) && defined($1),
3284 'optional zero-width match at end of string');
3285 ok(("abc" =~ /^abc(\z)??/) && !defined($1),
3286 'optional zero-width match at end of string');
3292 "words"=~/(word|word|word)(?{push @got,$1})s$/;
3293 ok(@got==1,"TRIE optimation is working") or warn "# @got";
3295 "words"=~/(word|word|word)(?{push @got,$1})s$/i;
3296 ok(@got==1,"TRIEF optimisation is working") or warn "# @got";
3298 my @nums=map {int rand 1000} 1..100;
3299 my $re="(".(join "|",@nums).")";
3303 ok($_=~/$re/,"Trie nums");
3307 push @got,$1 while /$re/g;
3310 $count{$_}++ for @got;
3313 $ok=0 if --$count{$_}<0;
3315 ok($ok,"Trie min count matches");
3320 # LATIN SMALL/CAPITAL LETTER A WITH MACRON
3321 ok(("foba \x{101}foo" =~ qr/(foo|\x{100}foo|bar)/i) && $1 eq "\x{101}foo",
3322 "TRIEF + LATIN SMALL/CAPITAL LETTER A WITH MACRON");
3324 # LATIN SMALL/CAPITAL LETTER A WITH RING BELOW
3325 ok(("foba \x{1E01}foo" =~ qr/(foo|\x{1E00}foo|bar)/i) && $1 eq "\x{1E01}foo",
3326 "TRIEF + LATIN SMALL/CAPITAL LETTER A WITH RING BELOW");
3328 # DESERET SMALL/CAPITAL LETTER LONG I
3329 ok(("foba \x{10428}foo" =~ qr/(foo|\x{10400}foo|bar)/i) && $1 eq "\x{10428}foo",
3330 "TRIEF + DESERET SMALL/CAPITAL LETTER LONG I");
3332 # LATIN SMALL/CAPITAL LETTER A WITH RING BELOW + 'X'
3333 ok(("foba \x{1E01}xfoo" =~ qr/(foo|\x{1E00}Xfoo|bar)/i) && $1 eq "\x{1E01}xfoo",
3334 "TRIEF + LATIN SMALL/CAPITAL LETTER A WITH RING BELOW + 'X'");
3338 use charnames ':full';
3340 $s="\N{LATIN SMALL LETTER SHARP S}";
3341 ok(("foba ba$s" =~ qr/(foo|Ba$s|bar)/i)
3343 "TRIEF + LATIN SMALL LETTER SHARP S =~ ss");
3344 ok(("foba ba$s" =~ qr/(Ba$s|foo|bar)/i)
3346 "TRIEF + LATIN SMALL LETTER SHARP S =~ ss");
3347 ok(("foba ba$s" =~ qr/(foo|bar|Ba$s)/i)
3349 "TRIEF + LATIN SMALL LETTER SHARP S =~ ss");
3351 ok(("foba ba$s" =~ qr/(foo|Bass|bar)/i)
3353 "TRIEF + LATIN SMALL LETTER SHARP S =~ ss");
3355 ok(("foba ba$s" =~ qr/(foo|BaSS|bar)/i)
3357 "TRIEF + LATIN SMALL LETTER SHARP S =~ SS");
3363 my @normal=qw(these are some normal words);
3364 my $psycho=join "|",@normal,map chr $_,255..20000;
3365 ok(('these'=~/($psycho)/) && $1 eq 'these','Pyscho');
3368 # [perl #36207] mixed utf8 / latin-1 and case folding
3371 my $utf8 = "\xe9\x{100}"; chop $utf8;
3372 my $latin1 = "\xe9";
3374 ok($utf8 =~ /\xe9/i, "utf8/latin");
3375 ok($utf8 =~ /$latin1/i, "utf8/latin runtime");
3376 ok($utf8 =~ /(abc|\xe9)/i, "utf8/latin trie");
3377 ok($utf8 =~ /(abc|$latin1)/i, "utf8/latin trie runtime");
3379 ok("\xe9" =~ /$utf8/i, "# TODO latin/utf8");
3380 ok("\xe9" =~ /(abc|$utf8)/i, "# latin/utf8 trie");
3381 ok($latin1 =~ /$utf8/i, "# TODO latin/utf8 runtime");
3382 ok($latin1 =~ /(abc|$utf8)/i, "# latin/utf8 trie runtime");
3385 # [perl #37038] Global regular matches generate invalid pointers
3393 "# TODO assigning to original string should not corrupt match vars");