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