$| = 1;
-print "1..854\n";
+print "1..908\n";
BEGIN {
chdir 't' if -d 't';
print "not " unless chr(0x38c) =~ /\p{IsGreek}/; # singleton
print "ok 672\n";
+if (ord("A") == 65) {
##
## Test [:cntrl:]...
##
## Should probably put in tests for all the POSIX stuff, but not sure how to
## guarantee a specific locale......
##
-$AllBytes = join('', map { chr($_) } 0..255);
-($x = $AllBytes) =~ s/[[:cntrl:]]//g;
-if ($x ne join('', map { chr($_) } 0x20..0x7E, 0x80..0xFF)) { print "not " };
-print "ok 673\n";
+ $AllBytes = join('', map { chr($_) } 0..255);
+ ($x = $AllBytes) =~ s/[[:cntrl:]]//g;
+ if ($x ne join('', map { chr($_) } 0x20..0x7E, 0x80..0xFF)) {
+ print "not ";
+ }
+ print "ok 673\n";
-($x = $AllBytes) =~ s/[^[:cntrl:]]//g;
-if ($x ne join('', map { chr($_) } 0..0x1F, 0x7F)) { print "not " };
-print "ok 674\n";
+ ($x = $AllBytes) =~ s/[^[:cntrl:]]//g;
+ if ($x ne join('', map { chr($_) } 0..0x1F, 0x7F)) { print "not " }
+ print "ok 674\n";
+} else {
+ print "ok $_ # Skip: EBCDIC\n" for 673..674;
+}
# With /s modifier UTF8 chars were interpreted as bytes
{
print "not " unless "a\x{100}" =~ /A/i;
print "ok 754\n";
- print "not " unless "A\x{100}" =~ /A/i;
+ print "not " unless "A\x{100}" =~ /a/i;
print "ok 755\n";
print "not " unless "a\x{100}" =~ /a/i;
print "not " unless "a\x{100}" =~ /A\x{100}/i;
print "ok 762\n";
- print "not " unless "A\x{100}" =~ /A\x{100}/i;
+ print "not " unless "A\x{100}" =~ /a\x{100}/i;
print "ok 763\n";
print "not " unless "a\x{100}" =~ /a\x{100}/i;
print "not " unless "a\x{100}" =~ /[A]/i;
print "ok 766\n";
- print "not " unless "A\x{100}" =~ /[A]/i;
+ print "not " unless "A\x{100}" =~ /[a]/i;
print "ok 767\n";
print "not " unless "a\x{100}" =~ /[a]/i;
print "\x{400}AB" =~ /(?<=\x{400}.)B/ ? "ok 853\n" : "not ok 853\n";
print "\x{500\x{600}}B" =~ /(?<=\x{500}.)B/ ? "ok 854\n" : "not ok 854\n";
}
+
+{
+ print "# UTF-8 hash keys and /\$/\n";
+ # http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2002-01/msg01327.html
+
+ my $u = "a\x{100}";
+ my $v = substr($u,0,1);
+ my $w = substr($u,1,1);
+ my %u = ( $u => $u, $v => $v, $w => $w );
+ my $i = 855;
+ for (keys %u) {
+ my $m1 = /^\w*$/ ? 1 : 0;
+ my $m2 = $u{$_}=~/^\w*$/ ? 1 : 0;
+ print $m1 == $m2 ? "ok $i\n" : "not ok $i # $m1 $m2\n";
+ $i++;
+ }
+}
+
+{
+ print "# [ID 20020124.005]\n";
+ # Fixed by #14795.
+ my $i = 858;
+ for my $char ("a", "\x{df}", "\x{100}"){
+ $x = "$char b $char";
+ $x =~ s{($char)}{
+ "c" =~ /c/;
+ "x";
+ }ge;
+ print substr($x,0,1) eq substr($x,-1,1) ?
+ "ok $i\n" : "not ok $i # debug: $x\n";
+ $i++;
+ }
+}
+
+{
+ print "# SEGV in s/// and UTF-8\n";
+ $s = "s#\x{100}" x 4;
+ $s =~ s/[^\w]/ /g;
+ print $s eq "s \x{100}" x 4 ? "ok 861\n" : "not ok 861\n";
+}
+
+{
+ print "# UTF-8 bug (maybe alreayd known?)\n";
+ my $u;
+
+ $u = "foo";
+ $u =~ s/./\x{100}/g;
+ print $u eq "\x{100}\x{100}\x{100}" ? "ok 862\n" : "not ok 862\n";
+
+ $u = "foobar";
+ $u =~ s/[ao]/\x{100}/g;
+ print $u eq "f\x{100}\x{100}b\x{100}r" ? "ok 863\n" : "not ok 863\n";
+
+ $u =~ s/\x{100}/e/g;
+ print $u eq "feeber" ? "ok 864\n" : "not ok 864\n";
+}
+
+{
+ print "# UTF-8 bug with s///\n";
+ # check utf8/non-utf8 mixtures
+ # try to force all float/anchored check combinations
+ my $c = "\x{100}";
+ my $test = 865;
+ my $subst;
+ for my $re (
+ "xx.*$c", "x.*$c$c", "$c.*xx", "$c$c.*x", "xx.*(?=$c)", "(?=$c).*xx",
+ ) {
+ print "xxx" =~ /$re/ ? "not ok $test\n" : "ok $test\n";
+ ++$test;
+ print +($subst = "xxx") =~ s/$re// ? "not ok $test\n" : "ok $test\n";
+ ++$test;
+ }
+ for my $re ("xx.*$c*", "$c*.*xx") {
+ print "xxx" =~ /$re/ ? "ok $test\n" : "not ok $test\n";
+ ++$test;
+ ($subst = "xxx") =~ s/$re//;
+ print $subst eq '' ? "ok $test\n" : "not ok $test\t# $subst\n";
+ ++$test;
+ }
+ for my $re ("xxy*", "y*xx") {
+ print "xx$c" =~ /$re/ ? "ok $test\n" : "not ok $test\n";
+ ++$test;
+ ($subst = "xx$c") =~ s/$re//;
+ print $subst eq $c ? "ok $test\n" : "not ok $test\n";
+ ++$test;
+ print "xy$c" =~ /$re/ ? "not ok $test\n" : "ok $test\n";
+ ++$test;
+ print +($subst = "xy$c") =~ /$re/ ? "not ok $test\n" : "ok $test\n";
+ ++$test;
+ }
+ for my $re ("xy$c*z", "x$c*yz") {
+ print "xyz" =~ /$re/ ? "ok $test\n" : "not ok $test\n";
+ ++$test;
+ ($subst = "xyz") =~ s/$re//;
+ print $subst eq '' ? "ok $test\n" : "not ok $test\n";
+ ++$test;
+ }
+}
+
+
+{
+ print "# Unicode hash keys and \\w\n";
+ # This is not really a regex test but regexes bring
+ # out the issue nicely.
+ use strict;
+ my $test = 893;
+ my $u3 = "f\x{df}\x{100}";
+ my $u2 = substr($u3,0,2);
+ my $u1 = substr($u2,0,1);
+ my %u = ( $u1 => $u1, $u2 => $u2, $u3 => $u3 );
+
+ for (keys %u) {
+ print /^\w+$/ && $u{$_} =~ /^\w+$/ ?
+ "ok $test\n" : "not ok $test\n";
+ $test++;
+ }
+
+ for (each %u) {
+ print /^\w+$/ && $u{$_} =~ /^\w+$/ ?
+ "ok $test\n" : "not ok $test\n";
+ $test++;
+ }
+
+ for (%u) {
+ print /^\w+$/ && $u{$_} =~ /^\w+$/ ?
+ "ok $test\n" : "not ok $test\n";
+ $test++;
+ }
+}
+
+{
+ print "# qr/.../x\n";
+ my $test = 904;
+
+ my $R = qr/ A B C # D E/x;
+
+ print eval {"ABCDE" =~ $R} ? "ok $test\n" : "not ok $test\n";
+ $test++;
+
+ print eval {"ABCDE" =~ m/$R/} ? "ok $test\n" : "not ok $test\n";
+ $test++;
+
+ print eval {"ABCDE" =~ m/($R)/} ? "ok $test\n" : "not ok $test\n";
+ $test++;
+}
+
+{
+ print "# illegal Unicode properties\n";
+ my $test = 907;
+
+ print eval { "a" =~ /\pq / } ? "not ok $test\n" : "ok $test\n";
+ $test++;
+
+ print eval { "a" =~ /\p{qrst} / } ? "not ok $test\n" : "ok $test\n";
+ $test++;
+}