Skip to content

Commit 4b6d59f

Browse files
committed
php/php-src 398f56d: Adjust tests for ICU 61.1 compatibility
Apply php/php-src commit 398f56d
1 parent af3d0e7 commit 4b6d59f

7 files changed

+236
-8
lines changed

ext/intl/tests/formatter_format6.phpt

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

ext/intl/tests/formatter_format7.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 >= 61.1
3+
--SKIPIF--
4+
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
<?php if (version_compare(INTL_ICU_VERSION, '61.1') < 0) die('skip for ICU >= 61.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+
'USD1,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( ¤)?'
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 ¤¤'
107+
108+
Locale is: fr
109+
'1234567.8912345\d+'
110+
'1 234 567,891'
111+
'1 234 567,89 ¤'
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 ¤¤'
119+
120+
Locale is: en_UK
121+
'1234567.8912345\d+'
122+
'1,234,567.891'
123+
'¤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+
'¤¤1,234,567.89'

ext/intl/tests/rbbiter_getBinaryRules_basic.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
IntlRuleBasedBreakIterator::getBinaryRules(): basic test
33
--SKIPIF--
44
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
<?php if (version_compare(INTL_ICU_VERSION, '61.1') >= 0) die('skip for ICU < 61.1'); ?>
56
<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip ICU >= 4.8 only'; ?>
67
--FILE--
78
<?php
@@ -22,7 +23,7 @@ $rules = <<<RULES
2223
!!safe_reverse;
2324
RULES;
2425
$rbbi = new IntlRuleBasedBreakIterator($rules);
25-
$rbbi->setText('sdfkjsdf88á.... ,;');;
26+
$rbbi->setText('sdfkjsdf88á.... ,;');
2627

2728
$br = $rbbi->getBinaryRules();
2829

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
--TEST--
2+
IntlRuleBasedBreakIterator::getBinaryRules(): basic test
3+
--SKIPIF--
4+
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
<?php if(version_compare(INTL_ICU_VERSION, '61.1') < 0) print 'skip ICU >= 61.1 only'; ?>
6+
--FILE--
7+
<?php
8+
ini_set("intl.error_level", E_WARNING);
9+
ini_set("intl.default_locale", "pt_PT");
10+
11+
$rules = <<<RULES
12+
\$LN = [[:letter:] [:number:]];
13+
\$S = [.;,:];
14+
15+
!!forward;
16+
\$LN+ {1};
17+
\$S+ {42};
18+
!!reverse;
19+
\$LN+ {1};
20+
\$S+ {42};
21+
!!safe_forward;
22+
!!safe_reverse;
23+
RULES;
24+
$rbbi = new IntlRuleBasedBreakIterator($rules);
25+
$rbbi->setText('sdfkjsdf88á.... ,;');
26+
27+
$br = $rbbi->getBinaryRules();
28+
29+
$rbbi2 = new IntlRuleBasedBreakIterator($br, true);
30+
31+
var_dump($rbbi->getRules(), $rbbi2->getRules());
32+
var_dump($rbbi->getRules() == $rbbi2->getRules());
33+
?>
34+
==DONE==
35+
--EXPECT--
36+
string(137) "$LN = [[:letter:] [:number:]];
37+
$S = [.;,:];
38+
!!forward;
39+
$LN+ {1};
40+
$S+ {42};
41+
!!reverse;
42+
$LN+ {1};
43+
$S+ {42};
44+
!!safe_forward;
45+
!!safe_reverse;"
46+
string(137) "$LN = [[:letter:] [:number:]];
47+
$S = [.;,:];
48+
!!forward;
49+
$LN+ {1};
50+
$S+ {42};
51+
!!reverse;
52+
$LN+ {1};
53+
$S+ {42};
54+
!!safe_forward;
55+
!!safe_reverse;"
56+
bool(true)
57+
==DONE==

ext/intl/tests/rbbiter_getRuleStatusVec_basic.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ $rules = <<<RULES
2525
!!safe_reverse;
2626
RULES;
2727
$rbbi = new IntlRuleBasedBreakIterator($rules);
28-
$rbbi->setText('sdfkjsdf88á.... ,;');;
28+
$rbbi->setText('sdfkjsdf88á.... ,;');
2929

3030
do {
3131
var_dump($rbbi->current(), $rbbi->getRuleStatusVec());
@@ -56,4 +56,4 @@ array(1) {
5656
[0]=>
5757
int(4)
5858
}
59-
==DONE==
59+
==DONE==

ext/intl/tests/rbbiter_getRules_basic.phpt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
--TEST--
22
IntlRuleBasedBreakIterator::getRules(): basic test
33
--SKIPIF--
4-
<?php
5-
if (!extension_loaded('intl'))
6-
die('skip intl extension not enabled');
4+
<?php if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
5+
<?php if (version_compare(INTL_ICU_VERSION, '61.1') >= 0) die('skip for ICU < 61.1'); ?>
76
--FILE--
87
<?php
98
ini_set("intl.error_level", E_WARNING);
@@ -29,4 +28,4 @@ var_dump($rbbi->getRules());
2928
==DONE==
3029
--EXPECT--
3130
string(128) "$LN = [[:letter:] [:number:]];$S = [.;,:];!!forward;$LN+ {1};$S+ {42};!!reverse;$LN+ {1};$S+ {42};!!safe_forward;!!safe_reverse;"
32-
==DONE==
31+
==DONE==
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
--TEST--
2+
IntlRuleBasedBreakIterator::getRules(): basic test
3+
--SKIPIF--
4+
<?php if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
5+
<?php if (version_compare(INTL_ICU_VERSION, '61.1') < 0) die('skip for ICU >= 61.1'); ?>
6+
--FILE--
7+
<?php
8+
ini_set("intl.error_level", E_WARNING);
9+
ini_set("intl.default_locale", "pt_PT");
10+
11+
$rules = <<<RULES
12+
\$LN = [[:letter:] [:number:]];
13+
\$S = [.;,:];
14+
15+
!!forward;
16+
\$LN+ {1};
17+
\$S+ {42};
18+
!!reverse;
19+
\$LN+ {1};
20+
\$S+ {42};
21+
!!safe_forward;
22+
!!safe_reverse;
23+
RULES;
24+
$rbbi = new IntlRuleBasedBreakIterator($rules);
25+
var_dump($rbbi->getRules());
26+
27+
?>
28+
==DONE==
29+
--EXPECT--
30+
string(137) "$LN = [[:letter:] [:number:]];
31+
$S = [.;,:];
32+
!!forward;
33+
$LN+ {1};
34+
$S+ {42};
35+
!!reverse;
36+
$LN+ {1};
37+
$S+ {42};
38+
!!safe_forward;
39+
!!safe_reverse;"
40+
==DONE==

0 commit comments

Comments
 (0)