1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
BEGIN {
unless ("A" eq pack('U', 0x41)) {
print "1..0 # Unicode::Collate " .
"cannot stringify a Unicode code point\n";
exit 0;
}
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,
UCA_Version => 9,
);
# rearrange : 0x0E40..0x0E44, 0x0EC0..0x0EC4 (default)
##### 2..9
my %old_rearrange = $Collator->change(rearrange => undef);
ok($Collator->gt( "\x{E41}A", "\x{E40}B"));
ok($Collator->gt("A\x{E41}A", "A\x{E40}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{E40}", "\x{E41}"));
ok($Collator->lt( "\x{E40}A", "\x{E41}B"));
ok($Collator->lt( "\x{E41}A", "\x{E40}B"));
ok($Collator->lt("A\x{E41}A", "A\x{E40}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{E40}", "\x{E41}"));
ok($all_undef_8->lt( "\x{E40}A", "\x{E41}B"));
ok($all_undef_8->lt( "\x{E41}A", "\x{E40}B"));
ok($all_undef_8->lt("A\x{E41}A", "A\x{E40}B"));
##### 14..18
my $no_rearrange = Unicode::Collate->new(
table => undef,
normalization => undef,
rearrange => [],
UCA_Version => 9,
);
ok($no_rearrange->lt("A", "B"));
ok($no_rearrange->lt( "\x{E40}", "\x{E41}"));
ok($no_rearrange->lt( "\x{E40}A", "\x{E41}B"));
ok($no_rearrange->gt( "\x{E41}A", "\x{E40}B"));
ok($no_rearrange->gt("A\x{E41}A", "A\x{E40}B"));
##### 19..23
my $undef_rearrange = Unicode::Collate->new(
table => undef,
normalization => undef,
rearrange => undef,
UCA_Version => 9,
);
ok($undef_rearrange->lt("A", "B"));
ok($undef_rearrange->lt( "\x{E40}", "\x{E41}"));
ok($undef_rearrange->lt( "\x{E40}A", "\x{E41}B"));
ok($undef_rearrange->gt( "\x{E41}A", "\x{E40}B"));
ok($undef_rearrange->gt("A\x{E41}A", "A\x{E40}B"));
|