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