Avoid potentially empty struct.
[p5sagit/p5-mst-13.2.git] / t / op / pat.t
index 82749a0..5681d6a 100755 (executable)
@@ -6,7 +6,7 @@
 
 $| = 1;
 
-print "1..908\n";
+print "1..910\n";
 
 BEGIN {
     chdir 't' if -d 't';
@@ -2772,40 +2772,9 @@ print "# some Unicode properties\n";
     }
 }
 
-
-{
-    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 $test = 893;
 
     my $R = qr/ A B C # D E/x;
 
@@ -2821,7 +2790,7 @@ print "# some Unicode properties\n";
 
 {
     print "# illegal Unicode properties\n";
-    my $test = 907;
+    my $test = 896;
 
     print eval { "a" =~ /\pq / }      ? "not ok $test\n" : "ok $test\n";
     $test++;
@@ -2829,3 +2798,89 @@ print "# some Unicode properties\n";
     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++;
+