Skip to content

Commit 22acea9

Browse files
committed
Merge branch 'PHP-5.5' of git.php.net:php-src into PHP-5.5
2 parents dae70a2 + 5b8c4b8 commit 22acea9

16 files changed

+1456
-27
lines changed

ext/intl/tests/bug62070.phpt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
--TEST--
22
Bug #62070: Collator::getSortKey() returns garbage
33
--SKIPIF--
4-
<?php
5-
if (!extension_loaded('intl'))
6-
die('skip intl extension not enabled');
7-
if (version_compare(INTL_ICU_VERSION, '49') < 0)
8-
die('skip ICU >= 49 only');
4+
<?php if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
5+
<?php if (version_compare(INTL_ICU_VERSION, '49') < 0) die('skip for ICU >= 49'); ?>
6+
<?php if (version_compare(INTL_ICU_VERSION, '53.1') >= 0) die('skip for ICU < 53.1'); ?>
97
--FILE--
108
<?php
119
$s1 = 'Hello';

ext/intl/tests/bug62070_2.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug #62070: Collator::getSortKey() returns garbage
3+
--SKIPIF--
4+
<?php if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
5+
<?php if (version_compare(INTL_ICU_VERSION, '53.1') < 0) die('skip for ICU >= 53.1'); ?>
6+
--FILE--
7+
<?php
8+
$s1 = 'Hello';
9+
10+
$coll = collator_create('en_US');
11+
$res = collator_get_sort_key($coll, $s1);
12+
13+
echo urlencode($res);
14+
--EXPECT--
15+
71%3F%3FE%01%09%01%DC%08

ext/intl/tests/collator_create2.phpt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
--TEST--
2-
create() icu >= 4.8
2+
create() icu >= 4.8 && icu < 53.1
33
--SKIPIF--
44
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5-
<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?>
5+
<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip for ICU >= 4.8'; ?>
6+
<?php if (version_compare(INTL_ICU_VERSION, '53.1') >= 0) die('skip for ICU < 53.1'); ?>
67
--FILE--
78
<?php
89

ext/intl/tests/collator_create3.phpt

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
--TEST--
2+
create() icu >= 53.1
3+
--SKIPIF--
4+
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
<?php if (version_compare(INTL_ICU_VERSION, '53.1') < 0) die('skip for ICU >= 53.1'); ?>
6+
--FILE--
7+
<?php
8+
9+
/*
10+
* Try creating collator with different locales
11+
* with Procedural and Object methods.
12+
*/
13+
14+
function ut_main()
15+
{
16+
$res_str = '';
17+
18+
$locales = array(
19+
'EN-US-ODESSA',
20+
'UK_UA_ODESSA',
21+
'uk-ua_CALIFORNIA@currency=;currency=GRN',
22+
'',
23+
'root',
24+
'uk@currency=EURO',
25+
'1234567891113151719212325272931333537394143454749515357596163656769717375777981838587899193959799'
26+
);
27+
28+
foreach( $locales as $locale )
29+
{
30+
// Create Collator with the current locale.
31+
$coll = ut_coll_create( $locale );
32+
if( !is_object($coll) )
33+
{
34+
$res_str .= "Error creating collator with '$locale' locale: " .
35+
intl_get_error_message() . "\n";
36+
continue;
37+
}
38+
39+
// Get the requested, valid and actual locales.
40+
$vloc = ut_coll_get_locale( $coll, Locale::VALID_LOCALE );
41+
$aloc = ut_coll_get_locale( $coll, Locale::ACTUAL_LOCALE );
42+
43+
// Show them.
44+
$res_str .= "Locale: '$locale'\n" .
45+
" ULOC_REQUESTED_LOCALE = '$locale'\n" .
46+
" ULOC_VALID_LOCALE = '$vloc'\n" .
47+
" ULOC_ACTUAL_LOCALE = '$aloc'\n";
48+
}
49+
50+
return $res_str;
51+
}
52+
53+
include_once( 'ut_common.inc' );
54+
ut_run();
55+
56+
?>
57+
--EXPECTF--
58+
Locale: 'EN-US-ODESSA'
59+
ULOC_REQUESTED_LOCALE = 'EN-US-ODESSA'
60+
ULOC_VALID_LOCALE = 'en_US'
61+
ULOC_ACTUAL_LOCALE = 'root'
62+
Locale: 'UK_UA_ODESSA'
63+
ULOC_REQUESTED_LOCALE = 'UK_UA_ODESSA'
64+
ULOC_VALID_LOCALE = 'uk'
65+
ULOC_ACTUAL_LOCALE = 'uk'
66+
Locale: 'uk-ua_CALIFORNIA@currency=;currency=GRN'
67+
ULOC_REQUESTED_LOCALE = 'uk-ua_CALIFORNIA@currency=;currency=GRN'
68+
ULOC_VALID_LOCALE = 'root'
69+
ULOC_ACTUAL_LOCALE = 'root'
70+
Locale: ''
71+
ULOC_REQUESTED_LOCALE = ''
72+
ULOC_VALID_LOCALE = '%s'
73+
ULOC_ACTUAL_LOCALE = '%s'
74+
Locale: 'root'
75+
ULOC_REQUESTED_LOCALE = 'root'
76+
ULOC_VALID_LOCALE = 'root'
77+
ULOC_ACTUAL_LOCALE = 'root'
78+
Locale: 'uk@currency=EURO'
79+
ULOC_REQUESTED_LOCALE = 'uk@currency=EURO'
80+
ULOC_VALID_LOCALE = 'uk'
81+
ULOC_ACTUAL_LOCALE = 'uk'
82+
Error creating collator with '1234567891113151719212325272931333537394143454749515357596163656769717375777981838587899193959799' locale: Locale string too long, should be no longer than 80 characters: U_ILLEGAL_ARGUMENT_ERROR

ext/intl/tests/collator_get_sort_key_variant2.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ collator_get_sort_key()
33
--SKIPIF--
44
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
55
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0) die('skip for ICU >= 51.2'); ?>
6+
<?php if (version_compare(INTL_ICU_VERSION, '53.1') >= 0) die('skip for ICU < 53.1'); ?>
67
--FILE--
78
<?php
89

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
--TEST--
2+
collator_get_sort_key()
3+
--SKIPIF--
4+
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
<?php if (version_compare(INTL_ICU_VERSION, '53.1') < 0) die('skip for ICU >= 53.1'); ?>
6+
--FILE--
7+
<?php
8+
9+
/*
10+
* Get sort keys using various locales
11+
*/
12+
function sort_arrays( $locale, $data )
13+
{
14+
$res_str = '';
15+
16+
$coll = ut_coll_create( $locale );
17+
18+
foreach($data as $value) {
19+
$res_val = ut_coll_get_sort_key( $coll, $value );
20+
$res_str .= "source: ".$value."\n".
21+
"key: ".bin2hex($res_val)."\n";
22+
}
23+
24+
return $res_str;
25+
}
26+
27+
28+
function ut_main()
29+
{
30+
$res_str = '';
31+
32+
// Regular strings keys
33+
$test_params = array(
34+
'abc', 'abd', 'aaa',
35+
'аа', 'а', 'z',
36+
'', null , '3',
37+
'y' , 'i' , 'k'
38+
);
39+
40+
$res_str .= sort_arrays( 'en_US', $test_params );
41+
42+
// Sort a non-ASCII array using ru_RU locale.
43+
$test_params = array(
44+
'абг', 'абв', 'жжж', 'эюя'
45+
);
46+
47+
$res_str .= sort_arrays( 'ru_RU', $test_params );
48+
49+
// Sort an array using Lithuanian locale.
50+
$res_str .= sort_arrays( 'lt_LT', $test_params );
51+
52+
return $res_str . "\n";
53+
}
54+
55+
include_once( 'ut_common.inc' );
56+
ut_run();
57+
?>
58+
--EXPECT--
59+
source: abc
60+
key: 292b2d01070107
61+
source: abd
62+
key: 292b2f01070107
63+
source: aaa
64+
key: 29292901070107
65+
source: аа
66+
key: 5e090901060106
67+
source: а
68+
key: 5e0901050105
69+
source: z
70+
key: 5b01050105
71+
source:
72+
key: 0101
73+
source:
74+
key: 0101
75+
source: 3
76+
key: 1a01050105
77+
source: y
78+
key: 5901050105
79+
source: i
80+
key: 3901050105
81+
source: k
82+
key: 3d01050105
83+
source: абг
84+
key: 2809131701070107
85+
source: абв
86+
key: 2809131501070107
87+
source: жжж
88+
key: 2833333301070107
89+
source: эюя
90+
key: 28cdd1d501070107
91+
source: абг
92+
key: 5e09131701070107
93+
source: абв
94+
key: 5e09131501070107
95+
source: жжж
96+
key: 5e33333301070107
97+
source: эюя
98+
key: 5ecdd1d501070107

ext/intl/tests/formatter_format2.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
numfmt_format() icu >= 4.8
33
--SKIPIF--
44
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5-
<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?>
5+
<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0 || version_compare(INTL_ICU_VERSION, '52.1') >= 0) print 'skip'; ?>
66
--FILE--
77
<?php
88

ext/intl/tests/formatter_format3.phpt

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
--TEST--
2+
numfmt_format() icu >= 52.1 && icu < 53.1
3+
--SKIPIF--
4+
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
<?php if(version_compare(INTL_ICU_VERSION, '52.1') < 0) print 'skip for ICU >= 52.1'; ?>
6+
<?php if (version_compare(INTL_ICU_VERSION, '53.1') >= 0) die('skip for ICU < 53.1'); ?>
7+
--FILE--
8+
<?php
9+
10+
/*
11+
* Format a number using misc locales/patterns.
12+
*/
13+
14+
/*
15+
* TODO: doesn't pass on ICU 3.6 because 'ru' and 'de' locales changed
16+
* currency and percent formatting.
17+
*/
18+
19+
function ut_main()
20+
{
21+
$styles = array(
22+
NumberFormatter::PATTERN_DECIMAL => '##.#####################',
23+
NumberFormatter::DECIMAL => '',
24+
NumberFormatter::CURRENCY => '',
25+
NumberFormatter::PERCENT => '',
26+
NumberFormatter::SCIENTIFIC => '',
27+
NumberFormatter::SPELLOUT => '@@@@@@@',
28+
NumberFormatter::ORDINAL => '',
29+
NumberFormatter::DURATION => '',
30+
NumberFormatter::PATTERN_RULEBASED => '#####.###',
31+
1234999, // bad one
32+
);
33+
34+
$integer = array(
35+
NumberFormatter::ORDINAL => '',
36+
NumberFormatter::DURATION => '',
37+
);
38+
$locales = array(
39+
'en_US',
40+
'ru_UA',
41+
'de',
42+
'fr',
43+
'en_UK'
44+
);
45+
46+
$str_res = '';
47+
$number = 1234567.891234567890000;
48+
49+
foreach( $locales as $locale )
50+
{
51+
$str_res .= "\nLocale is: $locale\n";
52+
foreach( $styles as $style => $pattern )
53+
{
54+
$fmt = ut_nfmt_create( $locale, $style, $pattern );
55+
56+
if(!$fmt) {
57+
$str_res .= "Bad formatter!\n";
58+
continue;
59+
}
60+
$str_res .= dump( isset($integer[$style])?ut_nfmt_format( $fmt, $number, NumberFormatter::TYPE_INT32):ut_nfmt_format( $fmt, $number ) ) . "\n";
61+
}
62+
}
63+
return $str_res;
64+
}
65+
66+
include_once( 'ut_common.inc' );
67+
68+
// Run the test
69+
ut_run();
70+
71+
?>
72+
--EXPECTREGEX--
73+
Locale is: en_US
74+
'1234567.89123457'
75+
'1,234,567.891'
76+
'\$1,234,567.89'
77+
'123,456,789%'
78+
'1.23456789123457E6'
79+
'one million,? two hundred (and )?thirty-four thousand,? five hundred (and )?sixty-seven point eight nine one two three four five seven'
80+
'1,234,567(th|ᵗʰ)'
81+
'342:56:07'
82+
'#####.###'
83+
Bad formatter!
84+
85+
Locale is: ru_UA
86+
'1234567,89123457'
87+
'1 234 567,891'
88+
'1 234 567,89 ?(грн\.|₴)'
89+
'123 456 789 ?%'
90+
'1,23456789123457E6'
91+
'один миллион двести тридцать четыре тысяч пятьсот шестьдесят семь запятая восемь девять один два три четыре пять семь'
92+
'1 234 567.?'
93+
'1 234 567'
94+
'#####.###'
95+
Bad formatter!
96+
97+
Locale is: de
98+
'1234567,89123457'
99+
'1.234.567,891'
100+
'(¤ )?1.234.567,89( ¤)?'
101+
'123\.456\.789 %'
102+
'1,23456789123457E6'
103+
'eine Million zwei­hundert­vier­und­dreißig­tausend­fünf­hundert­sieben­und­sechzig Komma acht neun eins zwei drei vier fünf sieben'
104+
'1.234.567.?'
105+
'1.234.567'
106+
'#####.###'
107+
Bad formatter!
108+
109+
Locale is: fr
110+
'1234567,89123457'
111+
'1 234 567,891'
112+
'1 234 567,89 ¤'
113+
'123 456 789 ?%'
114+
'1,23456789123457E6'
115+
'un million deux cent trente-quatre mille cinq cent soixante-sept virgule huit neuf un deux trois quatre cinq sept'
116+
'1 234 567e'
117+
'1 234 567'
118+
'#####.###'
119+
Bad formatter!
120+
121+
Locale is: en_UK
122+
'1234567.89123457'
123+
'1,234,567.891'
124+
'¤1,234,567.89'
125+
'123,456,789%'
126+
'1.23456789123457E6'
127+
'one million,? two hundred (and )?thirty-four thousand,? five hundred (and )?sixty-seven point eight nine one two three four five seven'
128+
'1,234,567(th|ᵗʰ)'
129+
'342:56:07'
130+
'#####.###'
131+
Bad formatter!

0 commit comments

Comments
 (0)