This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Updated Unicode-Collate to CPAN version 0.76
[perl5.git] / cpan / Unicode-Collate / t / cjk_ko.t
CommitLineData
68adb2b0
CBW
1
2BEGIN {
3 unless ("A" eq pack('U', 0x41)) {
4 print "1..0 # Unicode::Collate " .
5 "cannot stringify a Unicode code point\n";
6 exit 0;
7 }
8 if ($ENV{PERL_CORE}) {
9 chdir('t') if -d 't';
10 @INC = $^O eq 'MacOS' ? qw(::lib) : qw(../lib);
11 }
12}
13
14use Test;
19265284 15BEGIN { plan tests => 52 };
68adb2b0
CBW
16
17use strict;
18use warnings;
19use Unicode::Collate;
20
21ok(1);
22
23#########################
24
25use Unicode::Collate::CJK::Korean;
26
27my $collator = Unicode::Collate->new(
28 normalization => undef,
29 overrideCJK => \&Unicode::Collate::CJK::Korean::weightKorean
30);
31
19265284
CBW
32sub hex_sort {
33 my @source = map pack('U', hex $_), split ' ', shift;
34 my @sorted = $collator->sort(@source);
35 return join " ", map sprintf("%04X", unpack 'U', $_), @sorted;
36}
37
38# 1
39
68adb2b0
CBW
40$collator->change(level => 1);
41
42ok($collator->eq("\x{AC00}", "\x{4F3D}"));
43ok($collator->eq("\x{4F3D}", "\x{4F73}"));
44ok($collator->eq("\x{4F73}", "\x{5047}"));
45ok($collator->eq("\x{5047}", "\x{50F9}"));
46ok($collator->eq("\x{50F9}", "\x{52A0}"));
47ok($collator->eq("\x{52A0}", "\x{53EF}"));
48ok($collator->lt("\x{53EF}", "\x{AC01}"));
49
50ok($collator->eq("\x{AC1D}", "\x{5580}"));
51ok($collator->eq("\x{5580}", "\x{5BA2}"));
52ok($collator->lt("\x{5BA2}", "\x{AC31}"));
53
54ok($collator->eq("\x{C77C}", "\x{4E00}"));
55ok($collator->eq("\x{4E00}", "\x{4F5A}"));
56ok($collator->eq("\x{4F5A}", "\x{4F7E}"));
57
58ok($collator->lt("\x{993C}", "\x{D790}"));
59ok($collator->eq("\x{D790}", "\x{8A70}"));
60ok($collator->eq("\x{8A70}", "\x{72B5}"));
61ok($collator->eq("\x{72B5}", "\x{7E88}"));
62ok($collator->eq("\x{7E88}", "\x{896D}"));
63ok($collator->eq("\x{896D}", "\x{9821}"));
64ok($collator->eq("\x{9821}", "\x{9EE0}"));
65
66# Ext.B
67ok($collator->lt("\x{20000}", "\x{20001}"));
68ok($collator->lt("\x{20001}", "\x{20002}"));
69ok($collator->lt("\x{20002}", "\x{20003}"));
70ok($collator->lt("\x{20003}", "\x{20004}"));
71ok($collator->lt("\x{20004}", "\x{20005}"));
72
73# 26
74
75$collator->change(level => 2);
76
77ok($collator->lt("\x{AC00}", "\x{4F3D}"));
78ok($collator->lt("\x{4F3D}", "\x{4F73}"));
79ok($collator->lt("\x{4F73}", "\x{5047}"));
80ok($collator->lt("\x{5047}", "\x{50F9}"));
81ok($collator->lt("\x{50F9}", "\x{52A0}"));
82ok($collator->lt("\x{52A0}", "\x{53EF}"));
83ok($collator->lt("\x{53EF}", "\x{AC01}"));
84
85ok($collator->lt("\x{AC1D}", "\x{5580}"));
86ok($collator->lt("\x{5580}", "\x{5BA2}"));
87ok($collator->lt("\x{5BA2}", "\x{AC31}"));
88
89ok($collator->lt("\x{C77C}", "\x{4E00}"));
90ok($collator->lt("\x{4E00}", "\x{4F5A}"));
91ok($collator->lt("\x{4F5A}", "\x{4F7E}"));
92
93ok($collator->lt("\x{993C}", "\x{D790}"));
94ok($collator->lt("\x{D790}", "\x{8A70}"));
95ok($collator->lt("\x{8A70}", "\x{72B5}"));
96ok($collator->lt("\x{72B5}", "\x{7E88}"));
97ok($collator->lt("\x{7E88}", "\x{896D}"));
98ok($collator->lt("\x{896D}", "\x{9821}"));
99ok($collator->lt("\x{9821}", "\x{9EE0}"));
100
101# Ext.B
102ok($collator->lt("\x{20000}", "\x{20001}"));
103ok($collator->lt("\x{20001}", "\x{20002}"));
104ok($collator->lt("\x{20002}", "\x{20003}"));
105ok($collator->lt("\x{20003}", "\x{20004}"));
106ok($collator->lt("\x{20004}", "\x{20005}"));
107
108# 51
19265284
CBW
109
110ok(hex_sort('4E00 4E8C 4E09 56DB 4E94 516D 4E03 516B 4E5D 5341'),
111 '4E5D 516D 56DB 4E09 5341 4E94 4E8C 4E00 4E03 516B');
112
113# 52