$| = 1;
-print "1..675\n";
+print "1..747\n";
BEGIN {
chdir 't' if -d 't';
"#latin[$latin]\nnot ok $test\n";
$test++;
$latin =~ s/stra\337e/straße/; # \303\237 after the 2nd a
- use utf8;
+ use utf8; # needed for the raw UTF-8
$latin =~ s!(s)tr(?:aß|s+e)!$1tr.!; # \303\237 after the a
}
}
print "not " unless $#a == 12;
print "ok 675\n";
}
+
+@a = ("foo\nbar" =~ /./g);
+print "ok 676\n" if @a == 6 && "@a" eq "f o o b a r";
+
+@a = ("foo\nbar" =~ /./gs);
+print "ok 677\n" if @a == 7 && "@a" eq "f o o \n b a r";
+
+@a = ("foo\nbar" =~ /\C/g);
+print "ok 678\n" if @a == 7 && "@a" eq "f o o \n b a r";
+
+@a = ("foo\nbar" =~ /\C/gs);
+print "ok 679\n" if @a == 7 && "@a" eq "f o o \n b a r";
+
+@a = ("foo\n\x{100}bar" =~ /./g);
+print "ok 680\n" if @a == 7 && "@a" eq "f o o \x{100} b a r";
+
+@a = ("foo\n\x{100}bar" =~ /./gs);
+print "ok 681\n" if @a == 8 && "@a" eq "f o o \n \x{100} b a r";
+
+($a, $b) = map { chr } ord('A') == 65 ? (0xc4, 0x80) : (0x8c, 0x41);
+
+@a = ("foo\n\x{100}bar" =~ /\C/g);
+print "ok 682\n" if @a == 9 && "@a" eq "f o o \n $a $b b a r";
+
+@a = ("foo\n\x{100}bar" =~ /\C/gs);
+print "ok 683\n" if @a == 9 && "@a" eq "f o o \n $a $b b a r";
+
+{
+ # [ID 20010814.004] pos() doesn't work when using =~m// in list context
+ $_ = "ababacadaea";
+ $a = join ":", /b./gc;
+ $b = join ":", /a./gc;
+ $c = pos;
+ print "$a $b $c" eq 'ba:ba ad:ae 10' ? "ok 684\n" : "not ok 684\t# $a $b $c\n";
+}
+
+{
+ # [ID 20010407.006] matching utf8 return values from functions does not work
+
+ package ID_20010407_006;
+
+ sub x {
+ "a\x{1234}";
+ }
+
+ my $x = x;
+ my $y;
+
+ $x =~ /(..)/; $y = $1;
+ print "not " unless length($y) == 2 && $y eq $x;
+ print "ok 685\n";
+
+ x =~ /(..)/; $y = $1;
+ print "not " unless length($y) == 2 && $y eq $x;
+ print "ok 686\n";
+}
+
+
+my $test = 687;
+
+# Force scalar context on the patern match
+sub ok ($$) {
+ my($ok, $name) = @_;
+
+ printf "%sok %d - %s\n", ($ok ? "" : "not "), $test, $name;
+
+ printf "# Failed test at line %d\n", (caller)[2] unless $ok;
+
+ $test++;
+ return $ok;
+}
+
+{
+ # Check that \x## works. 5.6.1 and 5.005_03 fail some of these.
+ $x = "\x4e" . "E";
+ ok ($x =~ /^\x4EE$/, "Check only 2 bytes of hex are matched.");
+
+ $x = "\x4e" . "i";
+ ok ($x =~ /^\x4Ei$/, "Check that invalid hex digit stops it (2)");
+
+ $x = "\x4" . "j";
+ ok ($x =~ /^\x4j$/, "Check that invalid hex digit stops it (1)");
+
+ $x = "\x0" . "k";
+ ok ($x =~ /^\xk$/, "Check that invalid hex digit stops it (0)");
+
+ $x = "\x0" . "x";
+ ok ($x =~ /^\xx$/, "\\xx isn't to be treated as \\0");
+
+ $x = "\x0" . "xa";
+ ok ($x =~ /^\xxa$/, "\\xxa isn't to be treated as \\xa");
+
+ $x = "\x9" . "_b";
+ ok ($x =~ /^\x9_b$/, "\\x9_b isn't to be treated as \\x9b");
+
+ print "# and now again in [] ranges\n";
+
+ $x = "\x4e" . "E";
+ ok ($x =~ /^[\x4EE]{2}$/, "Check only 2 bytes of hex are matched.");
+
+ $x = "\x4e" . "i";
+ ok ($x =~ /^[\x4Ei]{2}$/, "Check that invalid hex digit stops it (2)");
+
+ $x = "\x4" . "j";
+ ok ($x =~ /^[\x4j]{2}$/, "Check that invalid hex digit stops it (1)");
+
+ $x = "\x0" . "k";
+ ok ($x =~ /^[\xk]{2}$/, "Check that invalid hex digit stops it (0)");
+
+ $x = "\x0" . "x";
+ ok ($x =~ /^[\xx]{2}$/, "\\xx isn't to be treated as \\0");
+
+ $x = "\x0" . "xa";
+ ok ($x =~ /^[\xxa]{3}$/, "\\xxa isn't to be treated as \\xa");
+
+ $x = "\x9" . "_b";
+ ok ($x =~ /^[\x9_b]{3}$/, "\\x9_b isn't to be treated as \\x9b");
+
+}
+
+{
+ # Check that \x{##} works. 5.6.1 fails quite a few of these.
+
+ $x = "\x9b";
+ ok ($x =~ /^\x{9_b}$/, "\\x{9_b} is to be treated as \\x9b");
+
+ $x = "\x9b" . "y";
+ ok ($x =~ /^\x{9_b}y$/, "\\x{9_b} is to be treated as \\x9b (again)");
+
+ $x = "\x9b" . "y";
+ ok ($x =~ /^\x{9b_}y$/, "\\x{9b_} is to be treated as \\x9b");
+
+ $x = "\x9b" . "y";
+ ok ($x =~ /^\x{9_bq}y$/, "\\x{9_bc} is to be treated as \\x9b");
+
+ $x = "\x0" . "y";
+ ok ($x =~ /^\x{x9b}y$/, "\\x{x9b} is to be treated as \\x0");
+
+ $x = "\x0" . "y";
+ ok ($x =~ /^\x{0x9b}y$/, "\\x{0x9b} is to be treated as \\x0");
+
+ $x = "\x9b" . "y";
+ ok ($x =~ /^\x{09b}y$/, "\\x{09b} is to be treated as \\x9b");
+
+ print "# and now again in [] ranges\n";
+
+ $x = "\x9b";
+ ok ($x =~ /^[\x{9_b}]$/, "\\x{9_b} is to be treated as \\x9b");
+
+ $x = "\x9b" . "y";
+ ok ($x =~ /^[\x{9_b}y]{2}$/, "\\x{9_b} is to be treated as \\x9b (again)");
+
+ $x = "\x9b" . "y";
+ ok ($x =~ /^[\x{9b_}y]{2}$/, "\\x{9b_} is to be treated as \\x9b");
+
+ $x = "\x9b" . "y";
+ ok ($x =~ /^[\x{9_bq}y]{2}$/, "\\x{9_bc} is to be treated as \\x9b");
+
+ $x = "\x0" . "y";
+ ok ($x =~ /^[\x{x9b}y]{2}$/, "\\x{x9b} is to be treated as \\x0");
+
+ $x = "\x0" . "y";
+ ok ($x =~ /^[\x{0x9b}y]{2}$/, "\\x{0x9b} is to be treated as \\x0");
+
+ $x = "\x9b" . "y";
+ ok ($x =~ /^[\x{09b}y]{2}$/, "\\x{09b} is to be treated as \\x9b");
+}
+
+{
+ # high bit bug -- japhy
+ my $x = "ab\200d";
+ $x =~ /.*?\200/ or print "not ";
+ print "ok 715\n";
+}
+
+print "# some Unicode properties\n";
+
+{
+ # Dashes, underbars, case.
+ print "not " unless "\x80" =~ /\p{in-latin1_SUPPLEMENT}/;
+ print "ok 716\n";
+
+ # Complement, leading and trailing whitespace.
+ print "not " unless "\x80" =~ /\P{ ^ In Latin 1 Supplement }/;
+ print "ok 717\n";
+
+ # No ^In, dashes, case, dash, any intervening (word-break) whitespace.
+ # (well, newlines don't work...)
+ print "not " unless "\x80" =~ /\p{latin-1 supplement}/;
+ print "ok 718\n";
+}
+
+{
+ print "not " unless "a" =~ /\pL/;
+ print "ok 719\n";
+
+ print "not " unless "a" =~ /\p{IsLl}/;
+ print "ok 720\n";
+
+ print "not " if "a" =~ /\p{IsLu}/;
+ print "ok 721\n";
+
+ print "not " unless "a" =~ /\p{Ll}/;
+ print "ok 722\n";
+
+ print "not " if "a" =~ /\p{Lu}/;
+ print "ok 723\n";
+
+ print "not " unless "A" =~ /\pL/;
+ print "ok 724\n";
+
+ print "not " unless "A" =~ /\p{IsLu}/;
+ print "ok 725\n";
+
+ print "not " if "A" =~ /\p{IsLl}/;
+ print "ok 726\n";
+
+ print "not " unless "A" =~ /\p{Lu}/;
+ print "ok 727\n";
+
+ print "not " if "A" =~ /\p{Ll}/;
+ print "ok 728\n";
+
+ print "not " if "a" =~ /\PL/;
+ print "ok 729\n";
+
+ print "not " if "a" =~ /\P{IsLl}/;
+ print "ok 730\n";
+
+ print "not " unless "a" =~ /\P{IsLu}/;
+ print "ok 731\n";
+
+ print "not " if "a" =~ /\P{Ll}/;
+ print "ok 732\n";
+
+ print "not " unless "a" =~ /\P{Lu}/;
+ print "ok 733\n";
+
+ print "not " if "A" =~ /\PL/;
+ print "ok 734\n";
+
+ print "not " if "A" =~ /\P{IsLu}/;
+ print "ok 735\n";
+
+ print "not " unless "A" =~ /\P{IsLl}/;
+ print "ok 736\n";
+
+ print "not " if "A" =~ /\P{Lu}/;
+ print "ok 737\n";
+
+ print "not " unless "A" =~ /\P{Ll}/;
+ print "ok 738\n";
+
+}
+
+{
+ print "not " if "a" =~ /\p{Common}/;
+ print "ok 739\n";
+
+ print "not " unless "1" =~ /\p{Common}/;
+ print "ok 740\n";
+}
+
+{
+ print "not " if "a" =~ /\p{Inherited}/;
+ print "ok 741\n";
+
+ print "not " unless "\x{300}" =~ /\p{Inherited}/;
+ print "ok 742\n";
+}
+
+{
+ print "not " unless "a" =~ /\p{L&}/;
+ print "ok 743\n";
+
+ print "not " if "1" =~ /\p{L&}/;
+ print "ok 744\n";
+}
+
+{
+ print "not " unless "a" =~ /\p{LowercaseLetter}/;
+ print "ok 745\n";
+
+ print "not " if "A" =~ /\p{LowercaseLetter}/;
+ print "ok 746\n";
+}
+
+{
+ print "not " unless "\x{AC00}" =~ /\p{HangulSyllable}/;
+ print "ok 747\n";
+}