1--TEST--
2numfmt_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
18function 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
65include_once( 'ut_common.inc' );
66
67// Run the test
68ut_run();
69
70?>
71--EXPECTREGEX--
72Locale 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
84Locale 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
96Locale 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
108Locale 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
120Locale 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'
131