summaryrefslogtreecommitdiff
path: root/t/uni/case.pl
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2002-02-18 14:54:47 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2002-02-18 14:54:47 +0000
commit23cd9172ab4c1e71bdfc3b5ce019766a0c5f966c (patch)
tree29c355d0f41e3d05abb1baa2e4359379024e5c88 /t/uni/case.pl
parent5284b67eb2f74db7dcaf6c897d9c70d6f197e486 (diff)
downloadperl-23cd9172ab4c1e71bdfc3b5ce019766a0c5f966c.tar.gz
More Unicode casing checks.
p4raw-id: //depot/perl@14744
Diffstat (limited to 't/uni/case.pl')
-rw-r--r--t/uni/case.pl76
1 files changed, 76 insertions, 0 deletions
diff --git a/t/uni/case.pl b/t/uni/case.pl
new file mode 100644
index 0000000000..25f8f4c977
--- /dev/null
+++ b/t/uni/case.pl
@@ -0,0 +1,76 @@
+use File::Spec;
+
+require "test.pl";
+
+sub casetest {
+ my ($base, $spec, $func) = @_;
+ my $file = File::Spec->catfile(File::Spec->catdir(File::Spec->updir,
+ "lib", "unicore", "To"),
+ "$base.pl");
+ my $simple = do $file;
+ my %simple;
+ for my $i (split(/\n/, $simple)) {
+ my ($k, $v) = split(' ', $i);
+ $simple{$k} = $v;
+ }
+ my %seen;
+
+ for my $i (sort keys %simple) {
+ $seen{hex $i}++;
+ }
+ print "# ", scalar keys %simple, " simple mappings\n";
+
+ my $both;
+
+ for my $i (sort keys %$spec) {
+ $both++ if ++$seen{hex $i} == 2;
+ }
+ print "# ", scalar keys %$spec, " special mappings\n";
+
+ my %none;
+ for my $i (map { ord } split //,
+ "\e !\"#\$%&'()+,-./0123456789:;<=>?\@[\\]^_{|}~\b") {
+ next if pack("U0U", $i) =~ /\w/;
+ $none{$i}++ unless $seen{$i};
+ }
+ print "# ", scalar keys %none, " noncase mappings\n";
+
+ my $tests =
+ (scalar keys %simple) +
+ (scalar keys %$spec) +
+ (scalar keys %none) - $both;
+ print "1..$tests\n";
+
+ my $test = 1;
+
+ for my $i (sort { hex $a <=> hex $b } keys %simple) {
+ my $w = "$i -> $simple{$i}";
+ my $c = pack "U0U", hex $i;
+ my $d = $func->($c);
+ print $d eq pack("U0U", hex $simple{$i}) ?
+ "ok $test # $w\n" : "not ok $test # $w\n";
+ $test++;
+ }
+
+ for my $i (sort { hex $a <=> hex $b } keys %$spec) {
+ next if $seen{hex $i} == 2;
+ my $w = qq[$i -> "] . display($spec->{$i}) . qq["];
+ my $c = pack "U0U", hex $i;
+ my $d = $func->($c);
+ print $d eq $spec->{$i} ?
+ "ok $test # $w\n" : "not ok $test # $w\n";
+ $test++;
+ }
+
+
+ for my $i (sort { $a <=> $b } keys %none) {
+ my $w = sprintf "%04X -> %04X", $i, $i;
+ my $c = pack "U0U", $i;
+ my $d = $func->($c);
+ print $d eq $c ?
+ "ok $test # $w\n" : "not ok $test # $w\n";
+ $test++;
+ }
+}
+
+1;