summaryrefslogtreecommitdiff
path: root/t/uni
diff options
context:
space:
mode:
authorTels <nospam-abuse@bloodgate.com>2005-06-29 23:19:52 +0200
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-06-30 10:01:55 +0000
commitcd1c2c6905a80e547b6f46f140e4e8bf42c8dc0d (patch)
treecef71ea6e646344471db3866ab2c3eaeb98c5271 /t/uni
parentcc8382cb63e73f1c3483d327d0b7d0f58659fd51 (diff)
downloadperl-cd1c2c6905a80e547b6f46f140e4e8bf42c8dc0d.tar.gz
make t/uni/class.t faster
Message-Id: <200506292120.05519@bloodgate.com> p4raw-id: //depot/perl@25020
Diffstat (limited to 't/uni')
-rw-r--r--t/uni/class.t44
1 files changed, 33 insertions, 11 deletions
diff --git a/t/uni/class.t b/t/uni/class.t
index 4ab06f7910..fa4cbf58ae 100644
--- a/t/uni/class.t
+++ b/t/uni/class.t
@@ -25,6 +25,30 @@ sub A::B::Intersection {
END
}
+sub test_regexp ($$) {
+ # test that given string consists of N-1 chars matching $qr1, and 1
+ # char matching $qr2
+ my ($str, $blk) = @_;
+
+ # constructing these objects here makes the last test loop go much faster
+ my $qr1 = qr/(\p{$blk}+)/;
+ if ($str =~ $qr1) {
+ is($1, substr($str, 0, -1)); # all except last char
+ }
+ else {
+ fail('first N-1 chars did not match');
+ }
+
+ my $qr2 = qr/(\P{$blk}+)/;
+ if ($str =~ $qr2) {
+ is($1, substr($str, -1)); # only last char
+ }
+ else {
+ fail('last char did not match');
+ }
+}
+
+use strict;
my $str = join "", map chr($_), 0x20 .. 0x6F;
@@ -106,8 +130,7 @@ for my $p ('gc', 'sc') {
for my $y ($abbr, $utf8::PropValueAlias{$p}{$abbr}, $utf8::PVA_abbr_map{gc_sc}{$abbr}) {
is($str =~ /(\p{$x: $y}+)/ && $1, substr($str, 0, -1));
is($str =~ /(\P{$x= $y}+)/ && $1, substr($str, -1));
- is($str =~ /(\p{$y}+)/ && $1, substr($str, 0, -1));
- is($str =~ /(\P{$y}+)/ && $1, substr($str, -1));
+ test_regexp ($str, $y);
}
}
}
@@ -127,7 +150,7 @@ SKIP:
my %files;
- my $dirname = File::Spec->catdir($updir => lib => unicore => lib => gc_sc);
+ my $dirname = File::Spec->catdir($updir => lib => unicore => lib => 'gc_sc');
opendir D, $dirname or die $!;
@files{readdir(D)} = ();
closedir D;
@@ -146,8 +169,7 @@ SKIP:
for my $y ($_, $utf8::PA_reverse{$_}) {
is($str =~ /(\p{$x: $y}+)/ && $1, substr($str, 0, -1));
is($str =~ /(\P{$x= $y}+)/ && $1, substr($str, -1));
- is($str =~ /(\p{$y}+)/ && $1, substr($str, 0, -1));
- is($str =~ /(\P{$y}+)/ && $1, substr($str, -1));
+ test_regexp ($str, $y);
}
}
}
@@ -160,16 +182,16 @@ for (grep $utf8::Canonical{$_} =~ /^In/, keys %utf8::Canonical) {
);
next unless -e $filename;
+
+ print "# In$_ $filename\n";
+
my ($h1, $h2) = map hex, (split(/\t/, (do $filename), 3))[0,1];
my $str = join "", map chr, $h1 .. (($h2 || $h1) + 1);
my $blk = $_;
- is($str =~ /(\p{$blk}+)/ && $1, substr($str, 0, -1));
- is($str =~ /(\P{$blk}+)/ && $1, substr($str, -1));
-
+ test_regexp ($str, $blk);
$blk =~ s/^In/Block:/;
-
- is($str =~ /(\p{$blk}+)/ && $1, substr($str, 0, -1));
- is($str =~ /(\P{$blk}+)/ && $1, substr($str, -1));
+ test_regexp ($str, $blk);
}
+