summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2002-01-05 22:09:20 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2002-01-05 22:09:20 +0000
commit9e55ce066d52428ee12b0c4df544c9a64f88c082 (patch)
tree52abfa57613cd9fbb4312fee9271e6b668819233 /lib
parentc7bdadfda7603b18f6db06d8065ed2a479a95e76 (diff)
downloadperl-9e55ce066d52428ee12b0c4df544c9a64f88c082.tar.gz
Finish up (ha!) the Unicode case folding;
enhance regex dumping code. p4raw-id: //depot/perl@14096
Diffstat (limited to 'lib')
-rw-r--r--lib/unifold.t45
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/unifold.t b/lib/unifold.t
new file mode 100644
index 0000000000..d4e819ecc7
--- /dev/null
+++ b/lib/unifold.t
@@ -0,0 +1,45 @@
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+}
+
+use File::Spec;
+
+my $CF = File::Spec->catfile(File::Spec->catdir(File::Spec->updir,
+ "lib", "unicore"),
+ "CaseFold.txt");
+
+if (open(CF, $CF)) {
+ my @CF;
+
+ while (<CF>) {
+ if (/^([0-9A-F]+); ([CFSI]); ((?:[0-9A-F]+)(?: [0-9A-F]+)*); \# (.+)/) {
+ next if $2 eq 'S'; # we are going for 'F'ull case folding
+ push @CF, [$1, $2, $3, $4];
+ }
+ }
+
+ die qq[$0: failed to find casefoldings from "$CF"\n] unless @CF;
+
+ print "1..", scalar @CF, "\n";
+
+ my $i = 0;
+ for my $cf (@CF) {
+ my ($code, $status, $mapping, $name) = @$cf;
+ $i++;
+ my $a = pack("U0U*", hex $code);
+ my $b = pack("U0U*", map { hex } split " ", $mapping);
+ my $t0 = ":$a:" =~ /:$a:/ ? 1 : 0;
+ my $t1 = ":$a:" =~ /:$a:/i ? 1 : 0;
+ my $t2 = ":$a:" =~ /:[$a]:/i ? 1 : 0;
+ my $t3 = ":$a:" =~ /:$b:/i ? 1 : 0;
+ my $t4 = ":$a:" =~ /:[$b]:/i ? 1 : 0;
+ my $t5 = ":$b:" =~ /:$a:/i ? 1 : 0;
+ my $t6 = ":$b:" =~ /:[$a]:/i ? 1 : 0;
+ print $t0 && $t1 && $t2 && $t3 && $t4 && $t5 && $t6 ?
+ "ok $i \# - $code - $name - $mapping - - $status\n" :
+ "not ok $i \# - $code - $name - $mapping - $t0 $t1 $t2 $t3 $t4 $t5 $t6 - $status\n";
+ }
+} else {
+ die qq[$0: failed to open "$CF": $!\n];
+}