$| = 1;
-print "1..903\n";
+print "1..910\n";
BEGIN {
chdir 't' if -d 't';
}
}
-
{
+ print "# qr/.../x\n";
my $test = 893;
- print "# Unicode hash keys and \\w\n";
- # This is not really a regex test but regexes bring
- # out the issue nicely.
- use strict;
- 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 );
+ my $R = qr/ A B C # D E/x;
- for (keys %u) {
- print /^\w+$/ && $u{$_} =~ /^\w+$/ ?
- "ok $test\n" : "not ok $test\n";
- $test++;
- }
+ print eval {"ABCDE" =~ $R} ? "ok $test\n" : "not ok $test\n";
+ $test++;
- for (each %u) {
- print /^\w+$/ && $u{$_} =~ /^\w+$/ ?
- "ok $test\n" : "not ok $test\n";
- $test++;
- }
+ print eval {"ABCDE" =~ m/$R/} ? "ok $test\n" : "not ok $test\n";
+ $test++;
- for (%u) {
- print /^\w+$/ && $u{$_} =~ /^\w+$/ ?
- "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 = 896;
+
+ 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++;
+}
+
+{
+ print "# [ID 20020412.005] wrong pmop flags checked when empty pattern\n";
+ # requires reuse of last successful pattern
+ my $test = 898;
+ $test =~ /\d/;
+ for (0 .. 1) {
+ my $match = ?? + 0;
+ if ($match != $_) {
+ print "ok $test\n";
+ } else {
+ printf "not ok %s\t# 'match once' %s on %s iteration\n", $test,
+ $match ? 'succeeded' : 'failed', $_ ? 'second' : 'first';
+ }
+ ++$test;
+ }
+ $test =~ /(\d)/;
+ my $result = join '', $test =~ //g;
+ if ($result eq $test) {
+ print "ok $test\n";
+ } else {
+ printf "not ok %s\t# expected '%s', got '%s'\n", $test, $test, $result;
+ }
+ ++$test;
+}
+
+print "# user-defined character properties\n";
+
+sub InKana1 {
+ return <<'END';
+3040 309F
+30A0 30FF
+END
+}
+
+sub InKana2 {
+ return <<'END';
++utf8::InHiragana
++utf8::InKatakana
+END
+}
+
+sub InKana3 {
+ return <<'END';
++utf8::InHiragana
++utf8::InKatakana
+-utf8::IsCn
+END
+}
+
+sub InNotKana {
+ return <<'END';
+!utf8::InHiragana
+-utf8::InKatakana
++utf8::IsCn
+END
}
+$test = 901;
+
+print "\x{3040}" =~ /\p{InKana1}/ ? "ok $test\n" : "not ok $test\n"; $test++;
+print "\x{303F}" =~ /\P{InKana1}/ ? "ok $test\n" : "not ok $test\n"; $test++;
+
+print "\x{3040}" =~ /\p{InKana2}/ ? "ok $test\n" : "not ok $test\n"; $test++;
+print "\x{303F}" =~ /\P{InKana2}/ ? "ok $test\n" : "not ok $test\n"; $test++;
+
+print "\x{3041}" =~ /\p{InKana3}/ ? "ok $test\n" : "not ok $test\n"; $test++;
+print "\x{3040}" =~ /\P{InKana3}/ ? "ok $test\n" : "not ok $test\n"; $test++;
+
+print "\x{3040}" =~ /\p{InNotKana}/ ? "ok $test\n" : "not ok $test\n"; $test++;
+print "\x{3041}" =~ /\P{InNotKana}/ ? "ok $test\n" : "not ok $test\n"; $test++;
+
+sub InConsonant { # Not EBCDIC-aware.
+ return <<EOF;
+0061 007f
+-0061
+-0065
+-0069
+-006f
+-0075
+EOF
+}
+
+print "d" =~ /\p{InConsonant}/ ? "ok $test\n" : "not ok $test\n"; $test++;
+print "e" =~ /\P{InConsonant}/ ? "ok $test\n" : "not ok $test\n"; $test++;
+