-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
356 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--TEST-- | ||
Bug #62070: Collator::getSortKey() returns garbage | ||
--SKIPIF-- | ||
<?php if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?> | ||
<?php if (version_compare(INTL_ICU_VERSION, '62.1') < 0) die('skip for ICU >= 62.1'); ?> | ||
--FILE-- | ||
<?php | ||
$s1 = 'Hello'; | ||
|
||
$coll = collator_create('en_US'); | ||
$res = collator_get_sort_key($coll, $s1); | ||
|
||
echo urlencode($res); | ||
--EXPECT-- | ||
82%40%40F%01%09%01%DC%08 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
--TEST-- | ||
collator_get_sort_key() icu >= 62.1 | ||
--SKIPIF-- | ||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> | ||
<?php if (version_compare(INTL_ICU_VERSION, '62.1') < 0) die('skip for ICU >= 62.1'); ?> | ||
--FILE-- | ||
<?php | ||
|
||
/* | ||
* Get sort keys using various locales | ||
*/ | ||
function sort_arrays( $locale, $data ) | ||
{ | ||
$res_str = ''; | ||
|
||
$coll = ut_coll_create( $locale ); | ||
|
||
foreach($data as $value) { | ||
$res_val = ut_coll_get_sort_key( $coll, $value ); | ||
$res_str .= "source: ".$value."\n". | ||
"key: ".bin2hex($res_val)."\n"; | ||
} | ||
|
||
return $res_str; | ||
} | ||
|
||
|
||
function ut_main() | ||
{ | ||
$res_str = ''; | ||
|
||
// Regular strings keys | ||
$test_params = array( | ||
'abc', 'abd', 'aaa', | ||
'аа', 'а', 'z', | ||
'', null , '3', | ||
'y' , 'i' , 'k' | ||
); | ||
|
||
$res_str .= sort_arrays( 'en_US', $test_params ); | ||
|
||
// Sort a non-ASCII array using ru_RU locale. | ||
$test_params = array( | ||
'абг', 'абв', 'жжж', 'эюя' | ||
); | ||
|
||
$res_str .= sort_arrays( 'ru_RU', $test_params ); | ||
|
||
// Sort an array using Lithuanian locale. | ||
$res_str .= sort_arrays( 'lt_LT', $test_params ); | ||
|
||
return $res_str . "\n"; | ||
} | ||
|
||
include_once( 'ut_common.inc' ); | ||
ut_run(); | ||
?> | ||
--EXPECT-- | ||
source: abc | ||
key: 2a2c2e01070107 | ||
source: abd | ||
key: 2a2c3001070107 | ||
source: aaa | ||
key: 2a2a2a01070107 | ||
source: аа | ||
key: 61060601060106 | ||
source: а | ||
key: 610601050105 | ||
source: z | ||
key: 5c01050105 | ||
source: | ||
key: 0101 | ||
source: | ||
key: 0101 | ||
source: 3 | ||
key: 1901050105 | ||
source: y | ||
key: 5a01050105 | ||
source: i | ||
key: 3a01050105 | ||
source: k | ||
key: 3e01050105 | ||
source: абг | ||
key: 27060c1001070107 | ||
source: абв | ||
key: 27060c0e01070107 | ||
source: жжж | ||
key: 272c2c2c01070107 | ||
source: эюя | ||
key: 27eef0f401070107 | ||
source: абг | ||
key: 61060c1001070107 | ||
source: абв | ||
key: 61060c0e01070107 | ||
source: жжж | ||
key: 612c2c2c01070107 | ||
source: эюя | ||
key: 61eef0f401070107 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
--TEST-- | ||
numfmt_format() icu >= 62.1 | ||
--SKIPIF-- | ||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> | ||
<?php if (version_compare(INTL_ICU_VERSION, '62.1') < 0) die('skip for ICU >= 62.1'); ?> | ||
--FILE-- | ||
<?php | ||
|
||
/* | ||
* Format a number using misc locales/patterns. | ||
*/ | ||
|
||
/* | ||
* TODO: doesn't pass on ICU 3.6 because 'ru' and 'de' locales changed | ||
* currency and percent formatting. | ||
*/ | ||
|
||
function ut_main() | ||
{ | ||
$styles = array( | ||
NumberFormatter::PATTERN_DECIMAL => '##.#####################', | ||
NumberFormatter::DECIMAL => '', | ||
NumberFormatter::CURRENCY => '', | ||
NumberFormatter::PERCENT => '', | ||
NumberFormatter::SCIENTIFIC => '', | ||
NumberFormatter::SPELLOUT => '@@@@@@@', | ||
NumberFormatter::ORDINAL => '', | ||
NumberFormatter::DURATION => '', | ||
NumberFormatter::PATTERN_RULEBASED => '#####.###', | ||
1234999, // bad one | ||
); | ||
|
||
$integer = array( | ||
NumberFormatter::ORDINAL => '', | ||
NumberFormatter::DURATION => '', | ||
); | ||
$locales = array( | ||
'en_US', | ||
'ru_UA', | ||
'de', | ||
'fr', | ||
'en_UK' | ||
); | ||
|
||
$str_res = ''; | ||
$number = 1234567.891234567890000; | ||
|
||
foreach( $locales as $locale ) | ||
{ | ||
$str_res .= "\nLocale is: $locale\n"; | ||
foreach( $styles as $style => $pattern ) | ||
{ | ||
$fmt = ut_nfmt_create( $locale, $style, $pattern ); | ||
|
||
if(!$fmt) { | ||
$str_res .= "Bad formatter!\n"; | ||
continue; | ||
} | ||
$str_res .= dump( isset($integer[$style])?ut_nfmt_format( $fmt, $number, NumberFormatter::TYPE_INT32):ut_nfmt_format( $fmt, $number ) ) . "\n"; | ||
} | ||
} | ||
return $str_res; | ||
} | ||
|
||
include_once( 'ut_common.inc' ); | ||
|
||
// Run the test | ||
ut_run(); | ||
|
||
?> | ||
--EXPECTREGEX-- | ||
Locale is: en_US | ||
'1234567.8912345\d+' | ||
'1,234,567.891' | ||
'\$1,234,567.89' | ||
'123,456,789%' | ||
'1.2345678912345\d+E6' | ||
'one million,? two hundred (and )?thirty-four thousand,? five hundred (and )?sixty-seven point eight nine one two three four five( six)? seven( nine)?' | ||
'1,234,567(th|ᵗʰ)' | ||
'342:56:07' | ||
'#####.###' | ||
'USD 1,234,567.89' | ||
|
||
Locale is: ru_UA | ||
'1234567.8912345\d+' | ||
'1 234 567,891' | ||
'1 234 567,89 ?(грн\.|₴)' | ||
'123 456 789 ?%' | ||
'1.2345678912345\d+E6' | ||
'один миллион двести тридцать четыре тысячи пятьсот шестьдесят семь целых восемьдесят девять миллионов сто двадцать три тысячи четыреста пятьдесят семь стомиллионных' | ||
'1 234 567.?' | ||
'1 234 567' | ||
'#####.###' | ||
'1 234 567,89 UAH' | ||
|
||
Locale is: de | ||
'1234567.8912345\d+' | ||
'1.234.567,891' | ||
'1.234.567,89 XXX' | ||
'123\.456\.789 %' | ||
'1.2345678912345\d+E6' | ||
'eine Million zweihundertvierunddreißigtausendfünfhundertsiebenundsechzig Komma acht neun eins zwei drei vier fünf( sechs)? sieben( neun)?' | ||
'1.234.567.?' | ||
'1.234.567' | ||
'#####.###' | ||
'1.234.567,89 XXX' | ||
|
||
Locale is: fr | ||
'1234567.8912345\d+' | ||
'1 234 567,891' | ||
'1 234 567,89 XXX' | ||
'123 456 789 ?%' | ||
'1.2345678912345\d+E6' | ||
'un million deux cent trente-quatre mille cinq cent soixante-sept virgule huit neuf un deux trois quatre cinq( six)? sept( neuf)?' | ||
'1 234 567e' | ||
'1 234 567' | ||
'#####.###' | ||
'1 234 567,89 XXX' | ||
|
||
Locale is: en_UK | ||
'1234567.8912345\d+' | ||
'1,234,567.891' | ||
'XXX 1,234,567.89' | ||
'123,456,789%' | ||
'1.2345678912345\d+E6' | ||
'one million,? two hundred (and )?thirty-four thousand,? five hundred (and )?sixty-seven point eight nine one two three four five( six)? seven( nine)?' | ||
'1,234,567(th|ᵗʰ)' | ||
'342:56:07' | ||
'#####.###' | ||
'XXX 1,234,567.89' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--TEST-- | ||
numfmt_get_locale() | ||
--SKIPIF-- | ||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> | ||
<?php if (version_compare(INTL_ICU_VERSION, '62.1') < 0) die('skip for ICU >= 62.1'); ?> | ||
--FILE-- | ||
<?php | ||
|
||
/* | ||
* Get locale. | ||
*/ | ||
|
||
function ut_main() | ||
{ | ||
$locales = array( | ||
'en_UK', | ||
'en_US', | ||
'fr_CA', | ||
); | ||
|
||
$loc_types = array( | ||
Locale::ACTUAL_LOCALE => 'actual', | ||
Locale::VALID_LOCALE => 'valid', | ||
); | ||
|
||
$res_str = ''; | ||
|
||
foreach( $locales as $locale ) | ||
{ | ||
$fmt = ut_nfmt_create( $locale, NumberFormatter::DECIMAL ); | ||
$res_str .= "$locale: "; | ||
foreach( $loc_types as $loc_type => $loc_type_name ) | ||
$res_str .= sprintf( " %s=%s", | ||
$loc_type_name, | ||
dump( ut_nfmt_get_locale( $fmt, $loc_type ) ) ); | ||
$res_str .= "\n"; | ||
} | ||
|
||
return $res_str; | ||
} | ||
|
||
include_once( 'ut_common.inc' ); | ||
|
||
// Run the test | ||
ut_run(); | ||
?> | ||
--EXPECT-- | ||
en_UK: actual='en' valid='en' | ||
en_US: actual='en_US' valid='en_US' | ||
fr_CA: actual='fr_CA' valid='fr_CA' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.