xref: /openbsd-src/gnu/usr.bin/perl/cpan/Unicode-Collate/t/compatui.t (revision 256a93a44f36679bee503f12e49566c2183f6181)
1898184e3Ssthen
2898184e3SsthenBEGIN {
3898184e3Ssthen    if ($ENV{PERL_CORE}) {
4898184e3Ssthen	chdir('t') if -d 't';
5898184e3Ssthen	@INC = $^O eq 'MacOS' ? qw(::lib) : qw(../lib);
6898184e3Ssthen    }
7898184e3Ssthen}
8898184e3Ssthen
9898184e3Ssthenuse strict;
10898184e3Ssthenuse warnings;
11*256a93a4Safresh1BEGIN { $| = 1; print "1..1331\n"; } # 1 + 70 x @Versions
12898184e3Ssthenmy $count = 0;
13898184e3Ssthensub ok ($;$) {
14898184e3Ssthen    my $p = my $r = shift;
15898184e3Ssthen    if (@_) {
16898184e3Ssthen	my $x = shift;
17898184e3Ssthen	$p = !defined $x ? !defined $r : !defined $r ? 0 : $r eq $x;
18898184e3Ssthen    }
19898184e3Ssthen    print $p ? "ok" : "not ok", ' ', ++$count, "\n";
20898184e3Ssthen}
21898184e3Ssthen
22898184e3Ssthenuse Unicode::Collate;
23898184e3Ssthen
24898184e3Ssthenok(1);
25898184e3Ssthen
26*256a93a4Safresh1sub _pack_U   { Unicode::Collate::pack_U(@_) }
27*256a93a4Safresh1sub _unpack_U { Unicode::Collate::unpack_U(@_) }
28*256a93a4Safresh1
29898184e3Ssthen#########################
30898184e3Ssthen
31*256a93a4Safresh1my @Versions = ( 8,  9, 11, 14, 16, 18, 20, 22, 24, 26,
32*256a93a4Safresh1		28, 30, 32, 34, 36, 38, 40, 41, 43);
33898184e3Ssthen
34898184e3Ssthen# 12 compatibility ideographs are treated as unified ideographs:
35898184e3Ssthen# FA0E, FA0F, FA11, FA13, FA14, FA1F, FA21, FA23, FA24, FA27, FA28, FA29.
36898184e3Ssthen
37898184e3Ssthenmy $Collator = Unicode::Collate->new(
38898184e3Ssthen    table => 'keys.txt',
39898184e3Ssthen    normalization => undef,
40898184e3Ssthen);
41898184e3Ssthen
42898184e3Ssthenfor my $v (@Versions) {
43898184e3Ssthen    $Collator->change(UCA_Version => $v);
44898184e3Ssthen    ok($Collator->lt("\x{4E00}", "\x{1FFF}"));
45898184e3Ssthen    ok($Collator->lt("\x{9FA5}", "\x{1FFF}"));
46898184e3Ssthen    ok($Collator->gt("\x{FA00}", "\x{1FFF}"));
47898184e3Ssthen    ok($Collator->gt("\x{FA0D}", "\x{1FFF}"));
48898184e3Ssthen    ok($Collator->lt("\x{FA0E}", "\x{1FFF}"));
49898184e3Ssthen    ok($Collator->lt("\x{FA0F}", "\x{1FFF}"));
50898184e3Ssthen    ok($Collator->gt("\x{FA10}", "\x{1FFF}"));
51898184e3Ssthen    ok($Collator->lt("\x{FA11}", "\x{1FFF}"));
52898184e3Ssthen    ok($Collator->gt("\x{FA12}", "\x{1FFF}"));
53898184e3Ssthen    ok($Collator->lt("\x{FA13}", "\x{1FFF}"));
54898184e3Ssthen    ok($Collator->lt("\x{FA14}", "\x{1FFF}"));
55898184e3Ssthen    ok($Collator->gt("\x{FA15}", "\x{1FFF}"));
56898184e3Ssthen    ok($Collator->gt("\x{FA16}", "\x{1FFF}"));
57898184e3Ssthen    ok($Collator->gt("\x{FA17}", "\x{1FFF}"));
58898184e3Ssthen    ok($Collator->gt("\x{FA18}", "\x{1FFF}"));
59898184e3Ssthen    ok($Collator->gt("\x{FA19}", "\x{1FFF}"));
60898184e3Ssthen    ok($Collator->gt("\x{FA1A}", "\x{1FFF}"));
61898184e3Ssthen    ok($Collator->gt("\x{FA1B}", "\x{1FFF}"));
62898184e3Ssthen    ok($Collator->gt("\x{FA1C}", "\x{1FFF}"));
63898184e3Ssthen    ok($Collator->gt("\x{FA1D}", "\x{1FFF}"));
64898184e3Ssthen    ok($Collator->gt("\x{FA1E}", "\x{1FFF}"));
65898184e3Ssthen    ok($Collator->lt("\x{FA1F}", "\x{1FFF}"));
66898184e3Ssthen    ok($Collator->gt("\x{FA20}", "\x{1FFF}"));
67898184e3Ssthen    ok($Collator->lt("\x{FA21}", "\x{1FFF}"));
68898184e3Ssthen    ok($Collator->gt("\x{FA22}", "\x{1FFF}"));
69898184e3Ssthen    ok($Collator->lt("\x{FA23}", "\x{1FFF}"));
70898184e3Ssthen    ok($Collator->lt("\x{FA24}", "\x{1FFF}"));
71898184e3Ssthen    ok($Collator->gt("\x{FA25}", "\x{1FFF}"));
72898184e3Ssthen    ok($Collator->gt("\x{FA26}", "\x{1FFF}"));
73898184e3Ssthen    ok($Collator->lt("\x{FA27}", "\x{1FFF}"));
74898184e3Ssthen    ok($Collator->lt("\x{FA28}", "\x{1FFF}"));
75898184e3Ssthen    ok($Collator->lt("\x{FA29}", "\x{1FFF}"));
76898184e3Ssthen    ok($Collator->gt("\x{FA2A}", "\x{1FFF}"));
77898184e3Ssthen    ok($Collator->gt("\x{FA30}", "\x{1FFF}"));
78898184e3Ssthen    ok($Collator->gt("\x{FAFF}", "\x{1FFF}"));
79898184e3Ssthen}
80898184e3Ssthen
81898184e3Ssthenmy $IgnoreCJK = Unicode::Collate->new(
82898184e3Ssthen    table => 'keys.txt',
83898184e3Ssthen    normalization => undef,
84898184e3Ssthen    overrideCJK => sub {()},
85898184e3Ssthen);
86898184e3Ssthen
87898184e3Ssthenfor my $v (@Versions) {
88898184e3Ssthen    $IgnoreCJK->change(UCA_Version => $v);
89898184e3Ssthen    ok($IgnoreCJK->eq("\x{4E00}", ""));
90898184e3Ssthen    ok($IgnoreCJK->eq("\x{9FA5}", ""));
91898184e3Ssthen    ok($IgnoreCJK->gt("\x{FA00}", "\x{1FFF}"));
92898184e3Ssthen    ok($IgnoreCJK->gt("\x{FA0D}", "\x{1FFF}"));
93898184e3Ssthen    ok($IgnoreCJK->eq("\x{FA0E}", ""));
94898184e3Ssthen    ok($IgnoreCJK->eq("\x{FA0F}", ""));
95898184e3Ssthen    ok($IgnoreCJK->gt("\x{FA10}", "\x{1FFF}"));
96898184e3Ssthen    ok($IgnoreCJK->eq("\x{FA11}", ""));
97898184e3Ssthen    ok($IgnoreCJK->gt("\x{FA12}", "\x{1FFF}"));
98898184e3Ssthen    ok($IgnoreCJK->eq("\x{FA13}", ""));
99898184e3Ssthen    ok($IgnoreCJK->eq("\x{FA14}", ""));
100898184e3Ssthen    ok($IgnoreCJK->gt("\x{FA15}", "\x{1FFF}"));
101898184e3Ssthen    ok($IgnoreCJK->gt("\x{FA16}", "\x{1FFF}"));
102898184e3Ssthen    ok($IgnoreCJK->gt("\x{FA17}", "\x{1FFF}"));
103898184e3Ssthen    ok($IgnoreCJK->gt("\x{FA18}", "\x{1FFF}"));
104898184e3Ssthen    ok($IgnoreCJK->gt("\x{FA19}", "\x{1FFF}"));
105898184e3Ssthen    ok($IgnoreCJK->gt("\x{FA1A}", "\x{1FFF}"));
106898184e3Ssthen    ok($IgnoreCJK->gt("\x{FA1B}", "\x{1FFF}"));
107898184e3Ssthen    ok($IgnoreCJK->gt("\x{FA1C}", "\x{1FFF}"));
108898184e3Ssthen    ok($IgnoreCJK->gt("\x{FA1D}", "\x{1FFF}"));
109898184e3Ssthen    ok($IgnoreCJK->gt("\x{FA1E}", "\x{1FFF}"));
110898184e3Ssthen    ok($IgnoreCJK->eq("\x{FA1F}", ""));
111898184e3Ssthen    ok($IgnoreCJK->gt("\x{FA20}", "\x{1FFF}"));
112898184e3Ssthen    ok($IgnoreCJK->eq("\x{FA21}", ""));
113898184e3Ssthen    ok($IgnoreCJK->gt("\x{FA22}", "\x{1FFF}"));
114898184e3Ssthen    ok($IgnoreCJK->eq("\x{FA23}", ""));
115898184e3Ssthen    ok($IgnoreCJK->eq("\x{FA24}", ""));
116898184e3Ssthen    ok($IgnoreCJK->gt("\x{FA25}", "\x{1FFF}"));
117898184e3Ssthen    ok($IgnoreCJK->gt("\x{FA26}", "\x{1FFF}"));
118898184e3Ssthen    ok($IgnoreCJK->eq("\x{FA27}", ""));
119898184e3Ssthen    ok($IgnoreCJK->eq("\x{FA28}", ""));
120898184e3Ssthen    ok($IgnoreCJK->eq("\x{FA29}", ""));
121898184e3Ssthen    ok($IgnoreCJK->gt("\x{FA2A}", "\x{1FFF}"));
122898184e3Ssthen    ok($IgnoreCJK->gt("\x{FA30}", "\x{1FFF}"));
123898184e3Ssthen    ok($IgnoreCJK->gt("\x{FAFF}", "\x{1FFF}"));
124898184e3Ssthen}
125898184e3Ssthen
126