Convert t/re/regexp_unicode_prop.t to using test.pl's functions for testing.
authorNicholas Clark <nick@ccl4.org>
Mon, 14 Mar 2011 11:29:19 +0000 (11:29 +0000)
committerNicholas Clark <nick@ccl4.org>
Mon, 14 Mar 2011 11:29:19 +0000 (11:29 +0000)
t/re/regexp_unicode_prop.t

index ee65dbd..54a2e7e 100644 (file)
@@ -169,15 +169,13 @@ push @CLASSES => "# Short properties"        => %SHORT_PROPERTIES,
 my $count = 0;
 for (my $i = 0; $i < @CLASSES; $i += 2) {
     $i ++, redo if $CLASSES [$i] =~ /^\h*#\h*(.*)/;
-    $count += (length $CLASSES [$i] == 1 ? 4 : 2) * @{$CLASSES [$i + 1]};
+    $count += 2 * (length $CLASSES [$i] == 1 ? 4 : 2) * @{$CLASSES [$i + 1]};
 }
-$count += 2 * @ILLEGAL_PROPERTIES;
-$count += 2 * grep {length $_ == 1} @ILLEGAL_PROPERTIES;
-$count += 4 * @USER_CASELESS_PROPERTIES;
+$count += 4 * @ILLEGAL_PROPERTIES;
+$count += 4 * grep {length $_ == 1} @ILLEGAL_PROPERTIES;
+$count += 8 * @USER_CASELESS_PROPERTIES;
 
-my $tests = 0;
-
-say "1..$count";
+plan(tests => $count);
 
 run_tests unless caller ();
 
@@ -205,13 +203,13 @@ sub match {
 
     undef $@;
     my $match_pat = eval "qr/$match/$caseless";
-    print "not " if $@ || ! ($str =~ /$match_pat/);
-    print "ok ", ++ $tests, " - $name =~ $match_pat\n";
+    is($@, '', "$name compiled correctly to a regexp");
+    like($str, $match_pat, "$name correctly matched");
 
     undef $@;
     my $nomatch_pat = eval "qr/$nomatch/$caseless";
-    print "not " if $@ || ! ($str !~ /$nomatch_pat/);
-    print "ok ", ++ $tests, " - $name !~ $nomatch_pat\n";
+    is($@, '', "$name compiled correctly to a regexp");
+    unlike($str, $nomatch_pat, "$name correctly did not match");
 }
 
 sub run_tests {
@@ -247,21 +245,21 @@ sub run_tests {
     foreach my $p (@ILLEGAL_PROPERTIES) {
         undef $@;
         my $r = eval "'a' =~ /\\p{$p}/; 1";
-        print "not " unless !$r && $@ && $@ =~ $pat;
-        print "ok ", ++ $tests, " - Unknown Unicode property \\p{$p}\n";
+        is($r, undef, "Unknown Unicode property \\p{$p}");
+        like($@, $pat, "Unknown Unicode property \\p{$p}");
         undef $@;
         my $s = eval "'a' =~ /\\P{$p}/; 1";
-        print "not " unless !$s && $@ && $@ =~ $pat;
-        print "ok ", ++ $tests, " - Unknown Unicode property \\P{$p}\n";
+        is($s, undef, "Unknown Unicode property \\p{$p}");
+        like($@, $pat, "Unknown Unicode property \\p{$p}");
         if (length $p == 1) {
             undef $@;
             my $r = eval "'a' =~ /\\p$p/; 1";
-            print "not " unless !$r && $@ && $@ =~ $pat;
-            print "ok ", ++ $tests, " - Unknown Unicode property \\p$p\n";
+            is($r, undef, "Unknown Unicode property \\p$p");
+            like($@, $pat, "Unknown Unicode property \\p$p");
             undef $@;
             my $s = eval "'a' =~ /\\P$p/; 1";
-            print "not " unless !$s && $@ && $@ =~ $pat;
-            print "ok ", ++ $tests, " - Unknown Unicode property \\P$p\n";
+            is($r, undef, "Unknown Unicode property \\P$p");
+            like($@, $pat, "Unknown Unicode property \\P$p");
         }
     }