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_st.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 => 26 };
68adb2b0
CBW
16
17use strict;
18use warnings;
19use Unicode::Collate;
20
21ok(1);
22
23#########################
24
25use Unicode::Collate::CJK::Stroke;
26
27my $collator = Unicode::Collate->new(
28 table => undef,
29 normalization => undef,
30 overrideCJK => \&Unicode::Collate::CJK::Stroke::weightStroke
31);
32
19265284
CBW
33sub hex_sort {
34 my @source = map pack('U', hex $_), split ' ', shift;
35 my @sorted = $collator->sort(@source);
36 return join " ", map sprintf("%04X", unpack 'U', $_), @sorted;
37}
38
39# 1
40
68adb2b0
CBW
41$collator->change(level => 1);
42
43ok($collator->lt("\x{4E00}", "\x{4E59}"));
44ok($collator->lt("\x{4E59}", "\x{4E01}"));
45ok($collator->lt("\x{4E01}", "\x{4E03}"));
46ok($collator->lt("\x{4E03}", "\x{4E43}"));
47ok($collator->lt("\x{4E43}", "\x{4E5D}"));
48ok($collator->lt("\x{4E5D}", "\x{4E86}"));
49ok($collator->lt("\x{4E86}", "\x{4E8C}"));
50ok($collator->lt("\x{4E8C}", "\x{4EBA}"));
51ok($collator->lt("\x{4EBA}", "\x{513F}"));
52ok($collator->lt("\x{513F}", "\x{5165}"));
53
54ok($collator->lt("\x{9E1D}", "\x{7069}"));
19265284
CBW
55ok($collator->lt("\x{7069}", "\x{706A}"));
56ok($collator->lt("\x{706A}", "\x{7C72}"));
57ok($collator->lt("\x{7C72}", "\x{7229}"));
68adb2b0
CBW
58ok($collator->lt("\x{7229}", "\x{9EA4}"));
59ok($collator->lt("\x{9EA4}", "\x{9F7E}"));
60ok($collator->lt("\x{9F7E}", "\x{9F49}"));
61ok($collator->lt("\x{9F49}", "\x{9F98}"));
62
63# Ext.B
64ok($collator->lt("\x{20000}", "\x{20001}"));
65ok($collator->lt("\x{20001}", "\x{20002}"));
66ok($collator->lt("\x{20002}", "\x{20003}"));
67ok($collator->lt("\x{20003}", "\x{20004}"));
68ok($collator->lt("\x{20004}", "\x{20005}"));
69
19265284
CBW
70# 24
71
72ok(hex_sort('4E00 4E8C 4E09 56DB 4E94 516D 4E03 516B 4E5D 5341'),
73 '4E00 4E03 4E5D 4E8C 516B 5341 4E09 4E94 516D 56DB');
74
75ok(hex_sort('4E0C 4E8D 4F5C 5140 554A 5750 57C3 5EA7 963F 9F3D 9F3E 9F44'),
76 '4E0C 4E8D 5140 4F5C 5750 963F 57C3 5EA7 554A 9F3D 9F3E 9F44');
77
78# 26