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