summaryrefslogtreecommitdiff
path: root/t/re/regexp_unicode_prop.t
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-03-14 11:29:19 +0000
committerNicholas Clark <nick@ccl4.org>2011-03-14 11:29:19 +0000
commit72d70e5644e8e9254a0e459933aaaec0b6fa01b3 (patch)
tree36daec08533a69e4f6efbadb3db70495adbb22c1 /t/re/regexp_unicode_prop.t
parente8fbc27bb8213e8bc971fbce5f4c90f2e391293a (diff)
downloadperl-72d70e5644e8e9254a0e459933aaaec0b6fa01b3.tar.gz
Convert t/re/regexp_unicode_prop.t to using test.pl's functions for testing.
Diffstat (limited to 't/re/regexp_unicode_prop.t')
-rw-r--r--t/re/regexp_unicode_prop.t36
1 files changed, 17 insertions, 19 deletions
diff --git a/t/re/regexp_unicode_prop.t b/t/re/regexp_unicode_prop.t
index ee65dbd65f..54a2e7e94a 100644
--- a/t/re/regexp_unicode_prop.t
+++ b/t/re/regexp_unicode_prop.t
@@ -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");
}
}