This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
f5cbc54680d82768646e0fc5bbeba9a8727af5d6
[perl5.git] / cpan / Unicode-Collate / t / loc_sidt.t
1
2 BEGIN {
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
14 use strict;
15 use warnings;
16 BEGIN { $| = 1; print "1..14\n"; }
17 my $count = 0;
18 sub ok ($;$) {
19     my $p = my $r = shift;
20     if (@_) {
21         my $x = shift;
22         $p = !defined $x ? !defined $r : !defined $r ? 0 : $r eq $x;
23     }
24     print $p ? "ok" : "not ok", ' ', ++$count, "\n";
25 }
26
27 use Unicode::Collate::Locale;
28
29 ok(1);
30
31 #########################
32
33 my $objSiDict = Unicode::Collate::Locale->
34     new(locale => 'SI-dict', normalization => undef);
35
36 ok($objSiDict->getlocale, 'si__dictionary');
37
38 $objSiDict->change(level => 2);
39
40 ok($objSiDict->gt("\x{DA5}", "\x{DA2}\x{DCA}\x{DA4}"));
41
42 $objSiDict->change(level => 1);
43
44 ok($objSiDict->eq("\x{DA5}", "\x{DA2}\x{DCA}\x{DA4}"));
45
46 ok($objSiDict->lt("\x{DA2}", "\x{DA5}"));
47 ok($objSiDict->lt("\x{DA5}", "\x{DA3}"));
48
49 # 6
50
51 for my $h (0, 1) {
52     no warnings 'utf8';
53     my $t = $h ? pack('U', 0xFFFF) : "";
54     $objSiDict->change(highestFFFF => 1) if $h;
55
56     ok($objSiDict->lt("\x{D95}$t", "\x{D96}"));
57     ok($objSiDict->lt("\x{D96}$t", "\x{D82}"));
58     ok($objSiDict->lt("\x{D82}$t", "\x{D83}"));
59     ok($objSiDict->lt("\x{D83}$t", "\x{D9A}"));
60 }
61
62 # 14