1
2BEGIN {
3    unless ('A' eq pack('U', 0x41)) {
4	print "1..0 # Unicode::Collate cannot pack a Unicode code point\n";
5	exit 0;
6    }
7    unless (0x41 == unpack('U', 'A')) {
8	print "1..0 # Unicode::Collate cannot get a Unicode code point\n";
9	exit 0;
10    }
11    if ($ENV{PERL_CORE}) {
12	chdir('t') if -d 't';
13	@INC = $^O eq 'MacOS' ? qw(::lib) : qw(../lib);
14    }
15}
16
17use strict;
18use warnings;
19BEGIN { $| = 1; print "1..69\n"; }
20my $count = 0;
21sub ok ($;$) {
22    my $p = my $r = shift;
23    if (@_) {
24	my $x = shift;
25	$p = !defined $x ? !defined $r : !defined $r ? 0 : $r eq $x;
26    }
27    print $p ? "ok" : "not ok", ' ', ++$count, "\n";
28}
29
30use Unicode::Collate::Locale;
31
32ok(1);
33
34#########################
35
36my $objLt = Unicode::Collate::Locale->
37    new(locale => 'LT', normalization => undef);
38
39ok($objLt->getlocale, 'lt');
40
41$objLt->change(level => 1);
42
43ok($objLt->lt("c", "c\x{30C}"));
44ok($objLt->gt("d", "c\x{30C}"));
45ok($objLt->lt("s", "s\x{30C}"));
46ok($objLt->gt("t", "s\x{30C}"));
47ok($objLt->lt("z", "z\x{30C}"));
48ok($objLt->lt("z\x{30C}", "\x{292}")); # U+0292 EZH
49
50# 8
51
52ok($objLt->eq("a", "a\x{328}"));
53ok($objLt->eq("e", "e\x{328}"));
54ok($objLt->eq("e\x{328}", "e\x{307}"));
55ok($objLt->eq("i", "i\x{328}"));
56ok($objLt->eq("y", "i\x{328}"));
57ok($objLt->eq("u", "u\x{328}"));
58ok($objLt->eq("u\x{328}", "u\x{304}"));
59
60# 15
61
62$objLt->change(level => 2);
63
64ok($objLt->lt("a", "a\x{328}"));
65ok($objLt->lt("e", "e\x{328}"));
66ok($objLt->lt("e\x{328}", "e\x{307}"));
67ok($objLt->lt("i", "i\x{328}"));
68ok($objLt->gt("y", "i\x{328}"));
69ok($objLt->lt("u", "u\x{328}"));
70ok($objLt->lt("u\x{328}", "u\x{304}"));
71
72# 22
73
74ok($objLt->eq("c\x{30C}", "C\x{30C}"));
75ok($objLt->eq("s\x{30C}", "S\x{30C}"));
76ok($objLt->eq("z\x{30C}", "Z\x{30C}"));
77
78ok($objLt->eq("i\x{307}", "I\x{307}"));
79ok($objLt->eq("y", "Y"));
80
81ok($objLt->eq("a\x{328}", "A\x{328}"));
82ok($objLt->eq("e\x{328}", "E\x{328}"));
83ok($objLt->eq("e\x{307}", "E\x{307}"));
84ok($objLt->eq("i\x{328}", "I\x{328}"));
85ok($objLt->eq("u\x{328}", "U\x{328}"));
86ok($objLt->eq("u\x{304}", "U\x{304}"));
87
88# 33
89
90# according to CLDR tests
91ok($objLt->gt("I\x{307}\x{300}", "I\x{300}"));
92ok($objLt->gt("I\x{307}\x{301}", "I\x{301}"));
93ok($objLt->gt("I\x{307}\x{303}", "I\x{303}"));
94
95# 36
96
97$objLt->change(level => 3);
98
99ok($objLt->lt("c\x{30C}", "C\x{30C}"));
100ok($objLt->lt("s\x{30C}", "S\x{30C}"));
101ok($objLt->lt("z\x{30C}", "Z\x{30C}"));
102
103ok($objLt->lt("i\x{307}", "I\x{307}"));
104ok($objLt->lt("y", "Y"));
105
106ok($objLt->lt("a\x{328}", "A\x{328}"));
107ok($objLt->lt("e\x{328}", "E\x{328}"));
108ok($objLt->lt("e\x{307}", "E\x{307}"));
109ok($objLt->lt("i\x{328}", "I\x{328}"));
110ok($objLt->lt("u\x{328}", "U\x{328}"));
111ok($objLt->lt("u\x{304}", "U\x{304}"));
112
113# 47
114
115ok($objLt->eq("c\x{30C}", "\x{10D}"));
116ok($objLt->eq("C\x{30C}", "\x{10C}"));
117ok($objLt->eq("s\x{30C}", "\x{161}"));
118ok($objLt->eq("S\x{30C}", "\x{160}"));
119ok($objLt->eq("z\x{30C}", "\x{17E}"));
120ok($objLt->eq("Z\x{30C}", "\x{17D}"));
121
122ok($objLt->eq("I\x{307}", "\x{130}"));
123
124ok($objLt->eq("a\x{328}", "\x{105}"));
125ok($objLt->eq("A\x{328}", "\x{104}"));
126ok($objLt->eq("e\x{328}", "\x{119}"));
127ok($objLt->eq("E\x{328}", "\x{118}"));
128ok($objLt->eq("e\x{307}", "\x{117}"));
129ok($objLt->eq("E\x{307}", "\x{116}"));
130ok($objLt->eq("i\x{328}", "\x{12F}"));
131ok($objLt->eq("I\x{328}", "\x{12E}"));
132ok($objLt->eq("u\x{328}", "\x{173}"));
133ok($objLt->eq("U\x{328}", "\x{172}"));
134ok($objLt->eq("u\x{304}", "\x{16B}"));
135ok($objLt->eq("U\x{304}", "\x{16A}"));
136
137# 66
138
139ok($objLt->eq("i\x{307}\x{300}", "i\x{300}"));
140ok($objLt->eq("i\x{307}\x{301}", "i\x{301}"));
141ok($objLt->eq("i\x{307}\x{303}", "i\x{303}"));
142
143# 69
144