Skip to content

Commit 5af0db8

Browse files
committed
Prepare tests for ICU 62.1
1 parent 701460b commit 5af0db8

12 files changed

+356
-5
lines changed

ext/intl/tests/bug62070_2.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Bug #62070: Collator::getSortKey() returns garbage
33
--SKIPIF--
44
<?php if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
55
<?php if (version_compare(INTL_ICU_VERSION, '53.1') < 0) die('skip for ICU >= 53.1'); ?>
6+
<?php if (version_compare(INTL_ICU_VERSION, '62.1') >= 0) die('skip for ICU < 62.1'); ?>
67
--FILE--
78
<?php
89
$s1 = 'Hello';

ext/intl/tests/bug62070_3.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, '62.1') < 0) die('skip for ICU >= 62.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+
82%40%40F%01%09%01%DC%08

ext/intl/tests/collator_get_sort_key_variant6.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ collator_get_sort_key() icu >= 56.1
33
--SKIPIF--
44
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
55
<?php if (version_compare(INTL_ICU_VERSION, '56.1') < 0) die('skip for ICU >= 56.1'); ?>
6+
<?php if (version_compare(INTL_ICU_VERSION, '62.1') >= 0) die('skip for ICU < 62.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() icu >= 62.1
3+
--SKIPIF--
4+
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
<?php if (version_compare(INTL_ICU_VERSION, '62.1') < 0) die('skip for ICU >= 62.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: 2a2c2e01070107
61+
source: abd
62+
key: 2a2c3001070107
63+
source: aaa
64+
key: 2a2a2a01070107
65+
source: аа
66+
key: 61060601060106
67+
source: а
68+
key: 610601050105
69+
source: z
70+
key: 5c01050105
71+
source:
72+
key: 0101
73+
source:
74+
key: 0101
75+
source: 3
76+
key: 1901050105
77+
source: y
78+
key: 5a01050105
79+
source: i
80+
key: 3a01050105
81+
source: k
82+
key: 3e01050105
83+
source: абг
84+
key: 27060c1001070107
85+
source: абв
86+
key: 27060c0e01070107
87+
source: жжж
88+
key: 272c2c2c01070107
89+
source: эюя
90+
key: 27eef0f401070107
91+
source: абг
92+
key: 61060c1001070107
93+
source: абв
94+
key: 61060c0e01070107
95+
source: жжж
96+
key: 612c2c2c01070107
97+
source: эюя
98+
key: 61eef0f401070107

ext/intl/tests/formatter_format7.phpt

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

ext/intl/tests/formatter_format8.phpt

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

ext/intl/tests/formatter_format_currency2.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ include_once( 'ut_common.inc' );
4242
ut_run();
4343

4444
?>
45-
--EXPECT--
45+
--EXPECTF--
4646
en_UK: '£1,234,567.89'
4747
en_US: '$1,234,567.89'
4848
ru: '1 234 567,89 р.'
4949
uk: '1 234 567,89 ₴'
50-
en: 'UAH1,234,567.89'
50+
en: 'UAH%A1,234,567.89'

ext/intl/tests/formatter_get_locale_variant3.phpt

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
--TEST--
2+
numfmt_get_locale()
3+
--SKIPIF--
4+
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
<?php if (version_compare(INTL_ICU_VERSION, '62.1') < 0) die('skip for ICU >= 62.1'); ?>
6+
--FILE--
7+
<?php
8+
9+
/*
10+
* Get locale.
11+
*/
12+
13+
function ut_main()
14+
{
15+
$locales = array(
16+
'en_UK',
17+
'en_US',
18+
'fr_CA',
19+
);
20+
21+
$loc_types = array(
22+
Locale::ACTUAL_LOCALE => 'actual',
23+
Locale::VALID_LOCALE => 'valid',
24+
);
25+
26+
$res_str = '';
27+
28+
foreach( $locales as $locale )
29+
{
30+
$fmt = ut_nfmt_create( $locale, NumberFormatter::DECIMAL );
31+
$res_str .= "$locale: ";
32+
foreach( $loc_types as $loc_type => $loc_type_name )
33+
$res_str .= sprintf( " %s=%s",
34+
$loc_type_name,
35+
dump( ut_nfmt_get_locale( $fmt, $loc_type ) ) );
36+
$res_str .= "\n";
37+
}
38+
39+
return $res_str;
40+
}
41+
42+
include_once( 'ut_common.inc' );
43+
44+
// Run the test
45+
ut_run();
46+
?>
47+
--EXPECT--
48+
en_UK: actual='en' valid='en'
49+
en_US: actual='en_US' valid='en_US'
50+
fr_CA: actual='fr_CA' valid='fr_CA'

ext/intl/tests/formatter_get_set_pattern.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
numfmt_get/set_pattern()
33
--SKIPIF--
44
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
<?php if (version_compare(INTL_ICU_VERSION, '62.1') >= 0) die('skip for ICU < 62.1'); ?>
56
--FILE--
67
<?php
78

0 commit comments

Comments
 (0)