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..51\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 $objHa = Unicode::Collate::Locale-> 37 new(locale => 'HA', normalization => undef); 38 39ok($objHa->getlocale, 'ha'); 40 41$objHa->change(level => 1); 42 43ok($objHa->lt("b", "\x{253}")); 44ok($objHa->gt("c", "\x{253}")); 45ok($objHa->lt("d", "\x{257}")); 46ok($objHa->gt("e", "\x{257}")); 47ok($objHa->lt("k", "\x{199}")); 48ok($objHa->gt("l", "\x{199}")); 49ok($objHa->lt("s", "sh")); 50ok($objHa->gt("t", "sh")); 51ok($objHa->lt("t", "ts")); 52ok($objHa->gt("u", "ts")); 53ok($objHa->lt("y", "\x{1B4}")); 54ok($objHa->gt("z", "\x{1B4}")); 55 56# 14 57 58$objHa->change(level => 2); 59 60ok($objHa->eq("\x{253}", "\x{181}")); 61ok($objHa->eq("\x{257}", "\x{18A}")); 62ok($objHa->eq("\x{199}", "\x{198}")); 63ok($objHa->eq("sh", "Sh")); 64ok($objHa->eq("Sh", "SH")); 65ok($objHa->eq("ts", "Ts")); 66ok($objHa->eq("Ts", "TS")); 67ok($objHa->eq("'y", "'Y")); 68ok($objHa->eq("\x{1B4}", "\x{1B3}")); 69 70ok($objHa->eq("\x{1B4}", "\x{2BC}y")); 71ok($objHa->eq("\x{2BC}y","'y")); 72ok($objHa->eq("'y", "\x{1B3}")); 73ok($objHa->eq("\x{1B3}", "\x{2BC}Y")); 74ok($objHa->eq("\x{2BC}Y","'Y")); 75ok($objHa->eq("'Y", "\x{1B4}")); 76 77# 29 78 79$objHa->change(level => 3); 80 81ok($objHa->lt("\x{253}", "\x{181}")); 82ok($objHa->lt("\x{257}", "\x{18A}")); 83ok($objHa->lt("\x{199}", "\x{198}")); 84ok($objHa->lt("sh", "Sh")); 85ok($objHa->lt("Sh", "SH")); 86ok($objHa->lt("ts", "Ts")); 87ok($objHa->lt("Ts", "TS")); 88ok($objHa->lt("'y", "'Y")); 89ok($objHa->lt("\x{1B4}", "\x{1B3}")); 90 91ok($objHa->lt("\x{1B4}", "\x{2BC}y")); 92ok($objHa->lt("\x{2BC}y","'y")); 93ok($objHa->lt("'y", "\x{1B3}")); 94ok($objHa->lt("\x{1B3}", "\x{2BC}Y")); 95ok($objHa->lt("\x{2BC}Y","'Y")); 96ok($objHa->gt("'Y", "\x{1B4}")); 97 98# 44 99 100$objHa->change(upper_before_lower => 1); 101 102ok($objHa->gt("\x{1B4}", "\x{1B3}")); 103ok($objHa->lt("\x{1B4}", "\x{2BC}y")); 104ok($objHa->lt("\x{2BC}y","'y")); 105ok($objHa->gt("'y", "\x{1B3}")); 106ok($objHa->lt("\x{1B3}", "\x{2BC}Y")); 107ok($objHa->lt("\x{2BC}Y","'Y")); 108ok($objHa->lt("'Y", "\x{1B4}")); 109 110# 51 111