summaryrefslogtreecommitdiff
path: root/lib/Unicode
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2003-12-27 18:29:44 +0000
committerNicholas Clark <nick@ccl4.org>2003-12-27 18:29:44 +0000
commit4b52b7fe4c8716b3c54e2056bf452b302e408935 (patch)
tree94ee155866c90c1b5825fc00ddd3a1276e0ba273 /lib/Unicode
parentabd1ec547ebff81b71080b2060165663ba730934 (diff)
downloadperl-4b52b7fe4c8716b3c54e2056bf452b302e408935.tar.gz
Straggler from Unicode::Collate.
We need to automate this. For some value of we. (tr/w/m/ I suspect) p4raw-id: //depot/perl@21977
Diffstat (limited to 'lib/Unicode')
-rw-r--r--lib/Unicode/Collate/t/rearrang.t97
1 files changed, 97 insertions, 0 deletions
diff --git a/lib/Unicode/Collate/t/rearrang.t b/lib/Unicode/Collate/t/rearrang.t
new file mode 100644
index 0000000000..cc02fa9f79
--- /dev/null
+++ b/lib/Unicode/Collate/t/rearrang.t
@@ -0,0 +1,97 @@
+
+BEGIN {
+ unless ("A" eq pack('U', 0x41)) {
+ print "1..0 # Unicode::Collate " .
+ "cannot stringify a Unicode code point\n";
+ exit 0;
+ }
+}
+
+BEGIN {
+ if ($ENV{PERL_CORE}) {
+ chdir('t') if -d 't';
+ @INC = $^O eq 'MacOS' ? qw(::lib) : qw(../lib);
+ }
+}
+
+use Test;
+BEGIN { plan tests => 23 };
+
+use strict;
+use warnings;
+use Unicode::Collate;
+
+ok(1);
+
+#########################
+
+my $Collator = Unicode::Collate->new(
+ table => 'keys.txt',
+ normalization => undef,
+);
+
+# rearrange : 0x0E40..0x0E44, 0x0EC0..0x0EC4 (default)
+
+##### 2..9
+
+my %old_rearrange = $Collator->change(rearrange => undef);
+
+ok($Collator->gt("\x{0E41}A", "\x{0E40}B"));
+ok($Collator->gt("A\x{0E41}A", "A\x{0E40}B"));
+
+$Collator->change(rearrange => [ 0x61 ]);
+ # U+0061, 'a': This is a Unicode value, never a native value.
+
+ok($Collator->gt("ab", "AB")); # as 'ba' > 'AB'
+
+$Collator->change(%old_rearrange);
+
+ok($Collator->lt("ab", "AB"));
+ok($Collator->lt("\x{0E40}", "\x{0E41}"));
+ok($Collator->lt("\x{0E40}A", "\x{0E41}B"));
+ok($Collator->lt("\x{0E41}A", "\x{0E40}B"));
+ok($Collator->lt("A\x{0E41}A", "A\x{0E40}B"));
+
+##### 10..13
+
+my $all_undef_8 = Unicode::Collate->new(
+ table => undef,
+ normalization => undef,
+ overrideCJK => undef,
+ overrideHangul => undef,
+ UCA_Version => 8,
+);
+
+ok($all_undef_8->lt("\x{0E40}", "\x{0E41}"));
+ok($all_undef_8->lt("\x{0E40}A", "\x{0E41}B"));
+ok($all_undef_8->lt("\x{0E41}A", "\x{0E40}B"));
+ok($all_undef_8->lt("A\x{0E41}A", "A\x{0E40}B"));
+
+##### 14..18
+
+my $no_rearrange = Unicode::Collate->new(
+ table => undef,
+ normalization => undef,
+ rearrange => [],
+);
+
+ok($no_rearrange->lt("A", "B"));
+ok($no_rearrange->lt("\x{0E40}", "\x{0E41}"));
+ok($no_rearrange->lt("\x{0E40}A", "\x{0E41}B"));
+ok($no_rearrange->gt("\x{0E41}A", "\x{0E40}B"));
+ok($no_rearrange->gt("A\x{0E41}A", "A\x{0E40}B"));
+
+##### 19..23
+
+my $undef_rearrange = Unicode::Collate->new(
+ table => undef,
+ normalization => undef,
+ rearrange => undef,
+);
+
+ok($undef_rearrange->lt("A", "B"));
+ok($undef_rearrange->lt("\x{0E40}", "\x{0E41}"));
+ok($undef_rearrange->lt("\x{0E40}A", "\x{0E41}B"));
+ok($undef_rearrange->gt("\x{0E41}A", "\x{0E40}B"));
+ok($undef_rearrange->gt("A\x{0E41}A", "A\x{0E40}B"));
+