3 unless ("A" eq pack('U', 0x41)) {
4 print "1..0 # Unicode::Collate " .
5 "cannot stringify a Unicode code point\n";
10 @INC = $^O eq 'MacOS' ? qw(::lib) : qw(../lib);
15 BEGIN { plan tests => 35 };
23 #########################
27 my $all_undef_8 = Unicode::Collate->new(
29 normalization => undef,
31 overrideHangul => undef,
35 # All in the Unicode code point order.
36 # No hangul decomposition.
38 ok($all_undef_8->lt("\x{3402}", "\x{4E00}"));
39 ok($all_undef_8->lt("\x{4DFF}", "\x{4E00}"));
40 ok($all_undef_8->lt("\x{4E00}", "\x{AC00}"));
41 ok($all_undef_8->gt("\x{AC00}", "\x{1100}\x{1161}"));
42 ok($all_undef_8->gt("\x{AC00}", "\x{ABFF}"));
47 my $all_undef_9 = Unicode::Collate->new(
49 normalization => undef,
51 overrideHangul => undef,
55 # CJK Ideo. < CJK ext A/B < Others.
56 # No hangul decomposition.
58 ok($all_undef_9->lt("\x{4E00}", "\x{3402}"));
59 ok($all_undef_9->lt("\x{3402}", "\x{20000}"));
60 ok($all_undef_9->lt("\x{20000}", "\x{AC00}"));
61 ok($all_undef_9->gt("\x{AC00}", "\x{1100}\x{1161}"));
62 ok($all_undef_9->gt("\x{AC00}", "\x{ABFF}")); # U+ABFF: not assigned
66 my $ignoreHangul = Unicode::Collate->new(
68 normalization => undef,
69 overrideHangul => sub {()},
71 AE00 ; [.0100.0020.0002.AE00] # Hangul GEUL
75 # All Hangul Syllables except U+AE00 are ignored.
77 ok($ignoreHangul->eq("\x{AC00}", ""));
78 ok($ignoreHangul->lt("\x{AC00}", "\0"));
79 ok($ignoreHangul->lt("\x{AC00}", "\x{AE00}"));
80 ok($ignoreHangul->lt("\x{AC00}", "\x{1100}\x{1161}")); # Jamo are not ignored.
81 ok($ignoreHangul->lt("Pe\x{AE00}rl", "Perl")); # 'r' is unassigned.
85 my $undefHangul = Unicode::Collate->new(
87 normalization => undef,
88 overrideHangul => sub {
90 return $u == 0xAE00 ? 0x100 : undef;
94 # All Hangul Syllables except U+AE00 are undefined.
96 ok($undefHangul->lt("\x{AE00}", "r"));
97 ok($undefHangul->gt("\x{AC00}", "r"));
98 ok($undefHangul->gt("\x{AC00}", "\x{1100}\x{1161}"));
99 ok($undefHangul->lt("Pe\x{AE00}rl", "Perl")); # 'r' is unassigned.
100 ok($undefHangul->lt("\x{AC00}", "\x{B000}"));
104 my $undefCJK = Unicode::Collate->new(
106 normalization => undef,
109 return $u == 0x4E00 ? 0x100 : undef;
113 # All CJK Ideographs except U+4E00 are undefined.
115 ok($undefCJK->lt("\x{4E00}", "r"));
116 ok($undefCJK->lt("\x{5000}", "r")); # still CJK < unassigned
117 ok($undefCJK->lt("Pe\x{4E00}rl", "Perl")); # 'r' is unassigned.
118 ok($undefCJK->lt("\x{5000}", "\x{6000}"));
122 my $cpHangul = Unicode::Collate->new(
124 normalization => undef,
125 overrideHangul => sub { shift }
128 ok($cpHangul->lt("\x{AC00}", "\x{AC01}"));
129 ok($cpHangul->lt("\x{AC01}", "\x{D7A3}"));
130 ok($cpHangul->lt("\x{D7A3}", "r")); # 'r' is unassigned.
131 ok($cpHangul->lt("r", "\x{D7A4}"));
132 ok($cpHangul->lt("\x{D7A3}", "\x{4E00}"));
136 my $arrayHangul = Unicode::Collate->new(
138 normalization => undef,
139 overrideHangul => sub {
141 return [$u, 0x20, 0x2, $u];
145 ok($arrayHangul->lt("\x{AC00}", "\x{AC01}"));
146 ok($arrayHangul->lt("\x{AC01}", "\x{D7A3}"));
147 ok($arrayHangul->lt("\x{D7A3}", "r")); # 'r' is unassigned.
148 ok($arrayHangul->lt("r", "\x{D7A4}"));
149 ok($arrayHangul->lt("\x{D7A3}", "\x{4E00}"));