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; 1191f110e0Safresh1BEGIN { $| = 1; print "1..134\n"; } 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::Locale; 23898184e3Ssthen 24898184e3Ssthenok(1); 25898184e3Ssthen 26*256a93a4Safresh1sub _pack_U { Unicode::Collate::pack_U(@_) } 27*256a93a4Safresh1sub _unpack_U { Unicode::Collate::unpack_U(@_) } 28*256a93a4Safresh1 29898184e3Ssthen######################### 30898184e3Ssthen 31898184e3Ssthenour (@listEs, @listEsT, @listFr); 32898184e3Ssthen 33898184e3Ssthen@listEs = qw( 34898184e3Ssthen cambio camella camello camelo Camer�n 35898184e3Ssthen chico chile Chile CHILE chocolate 36898184e3Ssthen cielo curso espacio espanto espa�ol esperanza lama l�quido 37898184e3Ssthen llama Llama LLAMA llamar luz nos nueve �u ojo 38898184e3Ssthen); 39898184e3Ssthen 40898184e3Ssthen@listEsT = qw( 41898184e3Ssthen cambio camelo camella camello Camer�n cielo curso 42898184e3Ssthen chico chile Chile CHILE chocolate 43898184e3Ssthen espacio espanto espa�ol esperanza lama l�quido luz 44898184e3Ssthen llama Llama LLAMA llamar nos nueve �u ojo 45898184e3Ssthen); 46898184e3Ssthen 47898184e3Ssthen@listFr = ( 48898184e3Ssthen qw( 49898184e3Ssthen cadurcien c�cum c�CUM C�CUM C�CUM caennais c�sium cafard 50898184e3Ssthen coercitif cote c�te C�te cot� Cot� c�t� C�t� coter 51898184e3Ssthen �l�ve �lev� g�ne g�ne M�CON ma�on 52898184e3Ssthen p�che P�CHE p�che P�CHE p�ch� P�CH� p�cher p�cher 53898184e3Ssthen rel�ve relev� r�v�le r�v�l� 54898184e3Ssthen sur�l�vation s�rement sur�minent s�ret� 55898184e3Ssthen vice-consul vicennal vice-pr�sident vice-roi vic�simal), 56898184e3Ssthen "vice versa", "vice-versa", 57898184e3Ssthen); 58898184e3Ssthen 59898184e3Ssthenok(@listEs, 27); 60898184e3Ssthenok(@listEsT, 27); 61898184e3Ssthenok(@listFr, 46); 62898184e3Ssthen 63898184e3Ssthenok(Unicode::Collate::Locale::_locale('es_MX'), 'es'); 64898184e3Ssthenok(Unicode::Collate::Locale::_locale('en_CA'), 'default'); 65898184e3Ssthen 66898184e3Ssthen# 6 67898184e3Ssthen 68898184e3Ssthenmy $Collator = Unicode::Collate::Locale-> 69898184e3Ssthen new(normalization => undef); 70898184e3Ssthenok($Collator->getlocale, 'default'); 71898184e3Ssthen 72898184e3Ssthenok( 73898184e3Ssthen join(':', $Collator->sort( 74898184e3Ssthen qw/ lib strict Carp ExtUtils CGI Time warnings Math overload Pod CPAN / 75898184e3Ssthen ) ), 76898184e3Ssthen join(':', 77898184e3Ssthen qw/ Carp CGI CPAN ExtUtils lib Math overload Pod strict Time warnings / 78898184e3Ssthen ), 79898184e3Ssthen); 80898184e3Ssthen 81898184e3Ssthenok($Collator->cmp("", ""), 0); 82898184e3Ssthenok($Collator->eq("", "")); 83898184e3Ssthenok($Collator->cmp("", "perl"), -1); 84898184e3Ssthenok($Collator->gt("PERL", "perl")); 85898184e3Ssthen 86898184e3Ssthen# 12 87898184e3Ssthen 88898184e3Ssthen$Collator->change(level => 2); 89898184e3Ssthen 90898184e3Ssthenok($Collator->eq("PERL", "perl")); 91898184e3Ssthen 92898184e3Ssthenmy $objEs = Unicode::Collate::Locale->new 93898184e3Ssthen (normalization => undef, locale => 'ES'); 94898184e3Ssthenok($objEs->getlocale, 'es'); 95898184e3Ssthen 96898184e3Ssthenmy $objEsT = Unicode::Collate::Locale->new 97898184e3Ssthen (normalization => undef, locale => 'es_ES_traditional'); 98898184e3Ssthenok($objEsT->getlocale, 'es__traditional'); 99898184e3Ssthen 100898184e3Ssthenmy $objFr = Unicode::Collate::Locale->new 1015759b3d2Safresh1 (normalization => undef, locale => 'FR_CA'); 1025759b3d2Safresh1ok($objFr->getlocale, 'fr_CA'); 103898184e3Ssthen 104898184e3Ssthen# 16 105898184e3Ssthen 106898184e3Ssthensub randomize { my %hash; @hash{@_} = (); keys %hash; } # ?! 107898184e3Ssthen 108898184e3Ssthenfor (my $i = 0; $i < $#listEs; $i++) { 109898184e3Ssthen ok($objEs->lt($listEs[$i], $listEs[$i+1])); 110898184e3Ssthen} 111898184e3Ssthen# 42 112898184e3Ssthen 113898184e3Ssthenfor (my $i = 0; $i < $#listEsT; $i++) { 114898184e3Ssthen ok($objEsT->lt($listEsT[$i], $listEsT[$i+1])); 115898184e3Ssthen} 116898184e3Ssthen# 68 117898184e3Ssthen 118898184e3Ssthenfor (my $i = 0; $i < $#listFr; $i++) { 119898184e3Ssthen ok($objFr->lt($listFr[$i], $listFr[$i+1])); 120898184e3Ssthen} 121898184e3Ssthen# 113 122898184e3Ssthen 123898184e3Ssthenour @randEs = randomize(@listEs); 124898184e3Ssthenour @sortEs = $objEs->sort(@randEs); 125898184e3Ssthenok("@sortEs" eq "@listEs"); 126898184e3Ssthen 127898184e3Ssthenour @randEsT = randomize(@listEsT); 128898184e3Ssthenour @sortEsT = $objEsT->sort(@randEsT); 129898184e3Ssthenok("@sortEsT" eq "@listEsT"); 130898184e3Ssthen 131898184e3Ssthenour @randFr = randomize(@listFr); 132898184e3Ssthenour @sortFr = $objFr->sort(@randFr); 133898184e3Ssthenok("@sortFr" eq "@listFr"); 134898184e3Ssthen 135898184e3Ssthen# 116 136898184e3Ssthen 137898184e3Ssthen{ 138898184e3Ssthen my $keyXS = '__useXS'; # see Unicode::Collate internal 139898184e3Ssthen my $noLoc = Unicode::Collate->new(normalization => undef); 140898184e3Ssthen my $UseXS = ref($noLoc->{$keyXS}); 141898184e3Ssthen ok(ref($Collator->{$keyXS}), $UseXS); 142898184e3Ssthen ok(ref($objFr ->{$keyXS}), $UseXS); 143898184e3Ssthen ok(ref($objEs ->{$keyXS}), $UseXS); 144898184e3Ssthen ok(ref($objEsT ->{$keyXS}), $UseXS); 145898184e3Ssthen} 146898184e3Ssthen# 120 147898184e3Ssthen 148898184e3Ssthenok(Unicode::Collate::Locale::_locale('sr'), 'sr'); 149898184e3Ssthenok(Unicode::Collate::Locale::_locale('sr_Cyrl'), 'sr'); 150898184e3Ssthenok(Unicode::Collate::Locale::_locale('sr_Latn'), 'sr_Latn'); 151898184e3Ssthenok(Unicode::Collate::Locale::_locale('sr_LATN'), 'sr_Latn'); 152898184e3Ssthenok(Unicode::Collate::Locale::_locale('sr_latn'), 'sr_Latn'); 153898184e3Ssthenok(Unicode::Collate::Locale::_locale('de'), 'default'); 154898184e3Ssthenok(Unicode::Collate::Locale::_locale('de_phone'), 'de__phonebook'); 155898184e3Ssthenok(Unicode::Collate::Locale::_locale('de__phonebook'), 'de__phonebook'); 156898184e3Ssthenok(Unicode::Collate::Locale::_locale('de-phonebk'), 'de__phonebook'); 157898184e3Ssthenok(Unicode::Collate::Locale::_locale('de--phonebk'), 'de__phonebook'); 158898184e3Ssthen 159898184e3Ssthen# 130 16091f110e0Safresh1 16191f110e0Safresh1my $objEs2 = Unicode::Collate::Locale->new 16291f110e0Safresh1 (normalization => undef, locale => 'ES', 16391f110e0Safresh1 level => 1, 16491f110e0Safresh1 entry => << 'ENTRIES', 16591f110e0Safresh10000 ; [.FFFE.0020.0005.0000] 16691f110e0Safresh100F1 ; [.0010.0020.0002.00F1] # LATIN SMALL LETTER N WITH TILDE 16791f110e0Safresh1006E 0303 ; [.0010.0020.0002.00F1] # LATIN SMALL LETTER N WITH TILDE 16891f110e0Safresh1ENTRIES 16991f110e0Safresh1); 17091f110e0Safresh1 17191f110e0Safresh1ok($objEs2->lt("abc\x{4E00}", "abc\0")); 17291f110e0Safresh1ok($objEs2->lt("abc\x{FFFD}", "abc\0")); 17391f110e0Safresh1ok($objEs2->lt("abc\x{FFFD}", "abc\0")); 17491f110e0Safresh1ok($objEs2->lt("n\x{303}", "N\x{303}")); 17591f110e0Safresh1 17691f110e0Safresh1# 134 17791f110e0Safresh1 178