diff options
Diffstat (limited to 'ext/intl/tests')
| -rw-r--r-- | ext/intl/tests/bug53735.phpt | 32 | ||||
| -rw-r--r-- | ext/intl/tests/bug69374.phpt | 24 | ||||
| -rw-r--r-- | ext/intl/tests/bug69398.phpt | 22 | ||||
| -rw-r--r-- | ext/intl/tests/bug70451.phpt | 12 | ||||
| -rw-r--r-- | ext/intl/tests/bug70452.phpt | 21 | ||||
| -rw-r--r-- | ext/intl/tests/bug72061.phpt | 15 | ||||
| -rw-r--r-- | ext/intl/tests/bug72241.phpt | 14 | ||||
| -rw-r--r-- | ext/intl/tests/dateformat_bug68893.phpt | 19 | ||||
| -rw-r--r-- | ext/intl/tests/dateformat_bug71516.phpt | 25 | ||||
| -rw-r--r-- | ext/intl/tests/grapheme.phpt | 24 | ||||
| -rw-r--r-- | ext/intl/tests/locale_bug66289.phpt | 27 | ||||
| -rw-r--r-- | ext/intl/tests/msgfmt_bug70484.phpt | 97 | ||||
| -rw-r--r-- | ext/intl/tests/timezone_IDforWindowsID_basic.phpt | 46 | ||||
| -rw-r--r-- | ext/intl/tests/timezone_getCanonicalID_error.phpt | 6 | ||||
| -rw-r--r-- | ext/intl/tests/timezone_windowsID_basic.phpt | 43 |
15 files changed, 421 insertions, 6 deletions
diff --git a/ext/intl/tests/bug53735.phpt b/ext/intl/tests/bug53735.phpt new file mode 100644 index 0000000000..5fc14e978c --- /dev/null +++ b/ext/intl/tests/bug53735.phpt @@ -0,0 +1,32 @@ +--TEST-- +Bug #53735 NumberFormatter returns NaN when converting float point +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0) die('skip for ICU >= 51.2'); ?> +--FILE-- +<?php + +$fmt = numfmt_create("da_DK", \NumberFormatter::CURRENCY); + +var_dump(numfmt_format($fmt, 5.5)); +setlocale(LC_ALL, "da_DK.UTF-8"); + +var_dump(numfmt_format($fmt, 5.5)); +var_dump(numfmt_format($fmt, "5,5")); + + +$fmt = new \NumberFormatter("de_DE", \NumberFormatter::DECIMAL); +var_dump($fmt->format(23.25)); + +$f = new NumberFormatter('hu_HU', NumberFormatter::PERCENT, '#,##0%'); +var_dump($f->format(0.26)); + +?> +==DONE== +--EXPECTF-- +string(%d) "5,50 kr%A" +string(%d) "5,50 kr%A" +string(%d) "5,00 kr%A" +string(5) "23,25" +string(3) "26%" +==DONE== diff --git a/ext/intl/tests/bug69374.phpt b/ext/intl/tests/bug69374.phpt new file mode 100644 index 0000000000..4d9fffab7a --- /dev/null +++ b/ext/intl/tests/bug69374.phpt @@ -0,0 +1,24 @@ +--TEST-- +IntlDateFormatter::formatObject(): returns wrong utf8 value when $format param is utf8 string pattern. +--SKIPIF-- +<?php +if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?> +<?php if (version_compare(INTL_ICU_VERSION, '50.1.2') < 0) die('skip for ICU >= 51.1.2'); ?> +--FILE-- +<?php +$millitimestamp = 1428133423941.0; // 14:43:43 April 04 2015 +$pattern1 = '\'tháng\' MM, y'; // yMM format for Vietnamese +$pattern2 = 'y년 MMM'; // yMM format for Korean +$date = IntlCalendar::createInstance('Asia/Ho_Chi_Minh'); +$date->setTime($millitimestamp); +echo IntlDateFormatter::formatObject($date, $pattern1, 'vi_VN'), "\n"; +echo IntlDateFormatter::formatObject ($date, $pattern2, 'ko_KR'), "\n"; +?> +==DONE== + +--EXPECTF-- +tháng 04, 2015 +2015년 4월 +==DONE== + + diff --git a/ext/intl/tests/bug69398.phpt b/ext/intl/tests/bug69398.phpt new file mode 100644 index 0000000000..ea7dbd5098 --- /dev/null +++ b/ext/intl/tests/bug69398.phpt @@ -0,0 +1,22 @@ +--TEST-- +IntlDateFormatter::formatObject(): returns wrong value when time style is NONE. +--SKIPIF-- +<?php +if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?> +<?php if (version_compare(INTL_ICU_VERSION, '50.1.2') < 0) die('skip for ICU >= 51.1.2'); ?> +--FILE-- +<?php +$millitimestamp = 1428133423941.0; // 14:43:43 April 04 2015 +$date = IntlCalendar::createInstance('Asia/Ho_Chi_Minh'); +$date->setTime($millitimestamp); +echo IntlDateFormatter::formatObject($date, array(IntlDateFormatter::SHORT, IntlDateFormatter::NONE), 'vi_VN'), "\n"; +echo IntlDateFormatter::formatObject ($date, array(IntlDateFormatter::SHORT, IntlDateFormatter::NONE), 'ko_KR'), "\n"; +?> +==DONE== + +--EXPECTF-- +04/04/2015 +15. 4. 4. +==DONE== + + diff --git a/ext/intl/tests/bug70451.phpt b/ext/intl/tests/bug70451.phpt new file mode 100644 index 0000000000..75392c8dad --- /dev/null +++ b/ext/intl/tests/bug70451.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #70451 IntlChar::charFromName() not consistent with C library or HHVM +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php +var_dump(IntlChar::charFromName("RECYCLING SYMBOL FOR TYPE-1 PLASTICS")); +var_dump(IntlChar::charFromName("sdfasdfasdfasdf")); +?> +--EXPECT-- +int(9843) +NULL diff --git a/ext/intl/tests/bug70452.phpt b/ext/intl/tests/bug70452.phpt new file mode 100644 index 0000000000..ee1cd7053a --- /dev/null +++ b/ext/intl/tests/bug70452.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #70452 string IntlChar::charName() can sometimes return bool(false) +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php +// Rely on the default value for the second parameter +var_dump(IntlChar::charName("A")); +// Provide a valid option for the second parameter +var_dump(IntlChar::charName("A", IntlChar::UNICODE_CHAR_NAME)); +// Another valid option, but with no corresponding name for that given option +// This properly returns an empty string, as expected +var_dump(IntlChar::charName("A", IntlChar::UNICODE_10_CHAR_NAME)); +// Provide an invalid value for the second parameter +var_dump(IntlChar::charName("A", 12345)); +?> +--EXPECT-- +string(22) "LATIN CAPITAL LETTER A" +string(22) "LATIN CAPITAL LETTER A" +string(0) "" +NULL diff --git a/ext/intl/tests/bug72061.phpt b/ext/intl/tests/bug72061.phpt new file mode 100644 index 0000000000..782c32c11c --- /dev/null +++ b/ext/intl/tests/bug72061.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #72061: Out-of-bounds reads in zif_grapheme_stripos with negative offset +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php + +var_dump(grapheme_stripos(str_repeat("ABCD", 16384), "A", -201)); +var_dump(grapheme_strpos(str_repeat("ABCD", 16384), "A", -201)); +?> +DONE +--EXPECT-- +int(65336) +int(65336) +DONE
\ No newline at end of file diff --git a/ext/intl/tests/bug72241.phpt b/ext/intl/tests/bug72241.phpt new file mode 100644 index 0000000000..397e1e7834 --- /dev/null +++ b/ext/intl/tests/bug72241.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #72241: get_icu_value_internal out-of-bounds read +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php +$var1=str_repeat("A", 1000); +$out = locale_get_primary_language($var1); +echo strlen($out) . PHP_EOL; +echo unpack('H*', $out)[1] . PHP_EOL; +--EXPECT-- +1000 +61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161 + diff --git a/ext/intl/tests/dateformat_bug68893.phpt b/ext/intl/tests/dateformat_bug68893.phpt new file mode 100644 index 0000000000..b3faf54342 --- /dev/null +++ b/ext/intl/tests/dateformat_bug68893.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #68893 Stackoverflow in datefmt_create +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php + +$f = datefmt_create("en_us", -10000000, 1); +var_dump($f, intl_get_error_message()); + +$f = datefmt_create("en_us", 1, -10000000); +var_dump($f, intl_get_error_message()); + +?> +--EXPECT-- +NULL +string(67) "datefmt_create: invalid date format style: U_ILLEGAL_ARGUMENT_ERROR" +NULL +string(67) "datefmt_create: invalid time format style: U_ILLEGAL_ARGUMENT_ERROR" diff --git a/ext/intl/tests/dateformat_bug71516.phpt b/ext/intl/tests/dateformat_bug71516.phpt new file mode 100644 index 0000000000..88ba9bf840 --- /dev/null +++ b/ext/intl/tests/dateformat_bug71516.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #71516 IntlDateFormatter losts locale if pattern is set via constructor +--SKIPIF-- +<?php +if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?> +--FILE-- +<?php + +$loc = "ru_RU"; +$goodFormatter = new IntlDateFormatter($loc, IntlDateFormatter::FULL, IntlDateFormatter::FULL, new DateTimeZone("UTC")); +$badFormatter = new IntlDateFormatter($loc, IntlDateFormatter::FULL, IntlDateFormatter::FULL, new DateTimeZone("UTC"), null, "d MMM"); +$badFormatter2 = new IntlDateFormatter($loc, IntlDateFormatter::FULL, IntlDateFormatter::FULL, new DateTimeZone("UTC")); +$badFormatter2->setPattern("d MMM"); + +echo "Formatter without pattern: " . $goodFormatter->getLocale() . PHP_EOL; +echo "Formatter with pattern: " . $badFormatter->getLocale() . PHP_EOL; +echo "Formatter with pattern set later: " . $badFormatter2->getLocale() . PHP_EOL; + +?> +==DONE== +--EXPECT-- +Formatter without pattern: ru +Formatter with pattern: ru +Formatter with pattern set later: ru +==DONE== diff --git a/ext/intl/tests/grapheme.phpt b/ext/intl/tests/grapheme.phpt index def9110d0d..251b1d142f 100644 --- a/ext/intl/tests/grapheme.phpt +++ b/ext/intl/tests/grapheme.phpt @@ -68,9 +68,13 @@ function ut_main() array( "abc", "a", 0 ), array( "abc", "a", 0, 0 ), array( "abc", "a", 1, "false" ), + array( "abc", "a", -1, "false" ), array( "ababc", "a", 1, 2 ), array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", 2, 6 ), + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", -1, 6 ), + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", -5, 6 ), array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 2, 3 ), + array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, -4, 3 ), array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "opq", "op", 5 ), array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "opq", "opq", 5 ), @@ -91,6 +95,7 @@ function ut_main() array( "ababc", "ab", 1, 2 ), array( "ababc", "abc", 1, 2 ), array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_a_ring_nfd . "bc", "o" . $char_a_ring_nfd . "bc", 2, 6 ), + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_a_ring_nfd . "bc", "o" . $char_a_ring_nfd . "bc", -8, 6 ), array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc" . $char_a_ring_nfd . "def", $char_a_ring_nfd . "bc" . $char_a_ring_nfd, 2, 3 ), ); @@ -120,10 +125,12 @@ function ut_main() $tests = array( array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", 2, 6 ), + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Oo", "o", -6, 6 ), array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, 2, 3 ), array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", 5 ), array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "O", "false" ), array( "a" . $char_a_ring_nfd . "bc" . $char_O_diaeresis_nfd, $char_o_diaeresis_nfd, 4 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_O_diaeresis_nfd, $char_o_diaeresis_nfd, -1, 4 ), array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_A_ring_nfd, 2 ), array( "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, 1 ), array( "Abc", $char_a_ring_nfd, "false" ), @@ -153,6 +160,7 @@ function ut_main() array( "aBc", "abC", 0, 0 ), array( "abc", "aBc", 1, "false" ), array( "ABabc", "AB", 1, 2 ), + array( "ABabc", "AB", -4, 2 ), array( "abaBc", "aBc", 1, 2 ), array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_A_ring_nfd . "bC", "O" . $char_a_ring_nfd . "bC", 2, 6 ), array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bC" . $char_a_ring_nfd . "def", $char_a_ring_nfd . "Bc" . $char_a_ring_nfd, 2, 3 ), @@ -559,6 +567,7 @@ function ut_main() array( "abc", 1, 0, 1, "a" ), array( "abc", 1, 1, 2, "b" ), array( "abc", 1, 2, 3, "c" ), + array( "abc", 1, -2, 2, "b" ), array( "abc", 0, 2, 2, "" ), array( "http://news.bbc.co.uk/2/hi/middle_east/7831588.stm", 48, 48 , 50 , "tm" ), @@ -569,8 +578,11 @@ function ut_main() array( $char_a_ring_nfd . "bc", 2, 0, 4, $char_a_ring_nfd . "b" ), array( $char_a_ring_nfd . "bc", 1, 0, 3, $char_a_ring_nfd . "" ), array( $char_a_ring_nfd . "bcde", 2, 3, 5, "bc" ), + array( $char_a_ring_nfd . "bcde", 2, -4, 5, "bc" ), array( $char_a_ring_nfd . "bcde", 2, 4, 6, "cd" ), + array( $char_a_ring_nfd . "bcde", 2, -7, 4, $char_a_ring_nfd . "b" ), array( $char_a_ring_nfd . "bcde" . $char_a_ring_nfd . "f", 4, 5, 11, "de" . $char_a_ring_nfd . "f" ), + array( $char_a_ring_nfd . "bcde" . $char_a_ring_nfd . "f", 4, -6, 11, "de" . $char_a_ring_nfd . "f" ), array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd ), array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, $char_a_ring_nfd . $char_o_diaeresis_nfd ), @@ -794,9 +806,13 @@ find "b" in "abc" - grapheme_strpos = 1 == 1 find "a" in "abc" - grapheme_strpos = 0 == 0 find "a" in "abc" - grapheme_strpos from 0 = 0 == 0 find "a" in "abc" - grapheme_strpos from 1 = false == false +find "a" in "abc" - grapheme_strpos from -1 = false == false find "a" in "ababc" - grapheme_strpos from 1 = 2 == 2 find "o" in "aoa%CC%8Abco%CC%88o" - grapheme_strpos from 2 = 6 == 6 +find "o" in "aoa%CC%8Abco%CC%88o" - grapheme_strpos from -1 = 6 == 6 +find "o" in "aoa%CC%8Abco%CC%88o" - grapheme_strpos from -5 = 6 == 6 find "a%CC%8A" in "o%CC%88a%CC%8Aaa%CC%8Abc" - grapheme_strpos from 2 = 3 == 3 +find "a%CC%8A" in "o%CC%88a%CC%8Aaa%CC%8Abc" - grapheme_strpos from -4 = 3 == 3 find "op" in "aa%CC%8Abco%CC%88opq" - grapheme_strpos = 5 == 5 find "opq" in "aa%CC%8Abco%CC%88opq" - grapheme_strpos = 5 == 5 find "abc" in "aa%CC%8Abco%CC%88" - grapheme_strpos = false == false @@ -816,15 +832,18 @@ find "abc" in "abc" - grapheme_strpos from 1 = false == false find "ab" in "ababc" - grapheme_strpos from 1 = 2 == 2 find "abc" in "ababc" - grapheme_strpos from 1 = 2 == 2 find "oa%CC%8Abc" in "aoa%CC%8Abco%CC%88oa%CC%8Abc" - grapheme_strpos from 2 = 6 == 6 +find "oa%CC%8Abc" in "aoa%CC%8Abco%CC%88oa%CC%8Abc" - grapheme_strpos from -8 = 6 == 6 find "a%CC%8Abca%CC%8A" in "o%CC%88a%CC%8Aaa%CC%8Abca%CC%8Adef" - grapheme_strpos from 2 = 3 == 3 function grapheme_stripos($haystack, $needle, $offset = 0) {} find "o" in "aoa%CC%8Abco%CC%88O" - grapheme_stripos from 2 = 6 == 6 +find "o" in "aoa%CC%8Abco%CC%88Oo" - grapheme_stripos from -6 = 6 == 6 find "a%CC%8A" in "o%CC%88a%CC%8AaA%CC%8Abc" - grapheme_stripos from 2 = 3 == 3 find "o" in "aa%CC%8Abco%CC%88O" - grapheme_stripos = 5 == 5 find "O" in "aa%CC%8Abco%CC%88" - grapheme_stripos = false == false find "o%CC%88" in "aa%CC%8AbcO%CC%88" - grapheme_stripos = 4 == 4 +find "o%CC%88" in "aa%CC%8AbcO%CC%88" - grapheme_stripos from -1 = 4 == 4 find "A%CC%8A" in "o%CC%88aa%CC%8Abc" - grapheme_stripos = 2 == 2 find "a%CC%8A" in "aA%CC%8Abc" - grapheme_stripos = 1 == 1 find "a%CC%8A" in "Abc" - grapheme_stripos = false == false @@ -853,6 +872,7 @@ find "ab" in "ABc" - grapheme_stripos from 0 = 0 == 0 find "abC" in "aBc" - grapheme_stripos from 0 = 0 == 0 find "aBc" in "abc" - grapheme_stripos from 1 = false == false find "AB" in "ABabc" - grapheme_stripos from 1 = 2 == 2 +find "AB" in "ABabc" - grapheme_stripos from -4 = 2 == 2 find "aBc" in "abaBc" - grapheme_stripos from 1 = 2 == 2 find "Oa%CC%8AbC" in "aoa%CC%8Abco%CC%88oA%CC%8AbC" - grapheme_stripos from 2 = 6 == 6 find "a%CC%8ABca%CC%8A" in "o%CC%88a%CC%8AaA%CC%8AbCa%CC%8Adef" - grapheme_stripos from 2 = 3 == 3 @@ -1094,6 +1114,7 @@ extract from "abc" "0" graphemes - grapheme_extract starting at byte position 0 extract from "abc" "1" graphemes - grapheme_extract starting at byte position 0 with $next = a == a $next=1 == 1 extract from "abc" "1" graphemes - grapheme_extract starting at byte position 1 with $next = b == b $next=2 == 2 extract from "abc" "1" graphemes - grapheme_extract starting at byte position 2 with $next = c == c $next=3 == 3 +extract from "abc" "1" graphemes - grapheme_extract starting at byte position -2 with $next = b == b $next=2 == 2 extract from "abc" "0" graphemes - grapheme_extract starting at byte position 2 with $next = == $next=2 == 2 extract from "http%3A%2F%2Fnews.bbc.co.uk%2F2%2Fhi%2Fmiddle_east%2F7831588.stm" "48" graphemes - grapheme_extract starting at byte position 48 with $next = tm == tm $next=50 == 50 extract from "a%CC%8Abc" "3" graphemes - grapheme_extract = a%CC%8Abc == a%CC%8Abc @@ -1103,8 +1124,11 @@ extract from "a%CC%8Abc" "3" graphemes - grapheme_extract starting at byte posit extract from "a%CC%8Abc" "2" graphemes - grapheme_extract starting at byte position 0 with $next = a%CC%8Ab == a%CC%8Ab $next=4 == 4 extract from "a%CC%8Abc" "1" graphemes - grapheme_extract starting at byte position 0 with $next = a%CC%8A == a%CC%8A $next=3 == 3 extract from "a%CC%8Abcde" "2" graphemes - grapheme_extract starting at byte position 3 with $next = bc == bc $next=5 == 5 +extract from "a%CC%8Abcde" "2" graphemes - grapheme_extract starting at byte position -4 with $next = bc == bc $next=5 == 5 extract from "a%CC%8Abcde" "2" graphemes - grapheme_extract starting at byte position 4 with $next = cd == cd $next=6 == 6 +extract from "a%CC%8Abcde" "2" graphemes - grapheme_extract starting at byte position -7 with $next = a%CC%8Ab == a%CC%8Ab $next=4 == 4 extract from "a%CC%8Abcdea%CC%8Af" "4" graphemes - grapheme_extract starting at byte position 5 with $next = dea%CC%8Af == dea%CC%8Af $next=11 == 11 +extract from "a%CC%8Abcdea%CC%8Af" "4" graphemes - grapheme_extract starting at byte position -6 with $next = dea%CC%8Af == dea%CC%8Af $next=11 == 11 extract from "a%CC%8Ao%CC%88o%CC%88" "3" graphemes - grapheme_extract = a%CC%8Ao%CC%88o%CC%88 == a%CC%8Ao%CC%88o%CC%88 extract from "a%CC%8Ao%CC%88o%CC%88" "2" graphemes - grapheme_extract = a%CC%8Ao%CC%88 == a%CC%8Ao%CC%88 extract from "a%CC%8Ao%CC%88c" "1" graphemes - grapheme_extract = a%CC%8A == a%CC%8A diff --git a/ext/intl/tests/locale_bug66289.phpt b/ext/intl/tests/locale_bug66289.phpt new file mode 100644 index 0000000000..6afd821b5a --- /dev/null +++ b/ext/intl/tests/locale_bug66289.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #66289 Locale::lookup incorrectly returns en or en_US if locale is empty +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php + +ini_set("intl.default_locale", "en-US"); +$availableLocales = array('fr_FR', 'de', 'es_ES', 'es_419', 'en_US'); +var_dump(locale_lookup($availableLocales, false, true, 'fr_FR')); +var_dump(locale_lookup($availableLocales, false, true, null)); + +$availableLocales = array('fr_FR', 'de', 'es_ES', 'es_419'); +var_dump(locale_lookup($availableLocales, false, true, 'fr_FR')); + +ini_set("intl.default_locale", "de-DE"); +$availableLocales = array(Locale::getDefault()); +var_dump(locale_lookup($availableLocales, false, true)); + +?> +==DONE== +--EXPECT-- +string(5) "fr_fr" +string(5) "en_us" +string(5) "fr_fr" +string(5) "de_de" +==DONE== diff --git a/ext/intl/tests/msgfmt_bug70484.phpt b/ext/intl/tests/msgfmt_bug70484.phpt new file mode 100644 index 0000000000..9d0bdc4ee8 --- /dev/null +++ b/ext/intl/tests/msgfmt_bug70484.phpt @@ -0,0 +1,97 @@ +--TEST-- +Bug #70484 selectordinal doesn't work with named parameters +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '5.0') < 0) + die('skip for ICU 5.0+'); +--FILE-- +<?php + +$locale = array("de", "fr", "en", "ru",); + +$data = array(42, 42.42, 2147483643, 2147483643.12345, 5); + +foreach ($locale as $lc) { + echo "$lc string key\n"; + $m = new MessageFormatter($lc, "{n, selectordinal, =5 {five} zero {#-zero} one {#-one} two {#-two} few {#-few} many {#-many} other {#-other}}"); + foreach ($data as $i) { + var_dump($m->format(array("n" => $i))); + if ($m->getErrorCode()) { + echo "$lc $i ", $m->getErrorMessage(); + } + } + echo "\n"; + + echo "$lc numeric key\n"; + $m = new MessageFormatter($lc, "{0, selectordinal, =5 {five} zero {#-zero} one {#-one} two {#-two} few {#-few} many {#-many} other {#-other}}"); + foreach ($data as $i) { + var_dump($m->format(array($i))); + if ($m->getErrorCode()) { + echo "$lc $i ", $m->getErrorMessage(); + } + } + echo "\n"; +} + +?> +==DONE== +--EXPECT-- +de string key +string(8) "42-other" +string(11) "42,42-other" +string(19) "2.147.483.643-other" +string(23) "2.147.483.643,123-other" +string(4) "five" + +de numeric key +string(8) "42-other" +string(11) "42,42-other" +string(19) "2.147.483.643-other" +string(23) "2.147.483.643,123-other" +string(4) "five" + +fr string key +string(8) "42-other" +string(11) "42,42-other" +string(22) "2 147 483 643-other" +string(26) "2 147 483 643,123-other" +string(4) "five" + +fr numeric key +string(8) "42-other" +string(11) "42,42-other" +string(22) "2 147 483 643-other" +string(26) "2 147 483 643,123-other" +string(4) "five" + +en string key +string(6) "42-two" +string(11) "42.42-other" +string(17) "2,147,483,643-few" +string(23) "2,147,483,643.123-other" +string(4) "five" + +en numeric key +string(6) "42-two" +string(11) "42.42-other" +string(17) "2,147,483,643-few" +string(23) "2,147,483,643.123-other" +string(4) "five" + +ru string key +string(8) "42-other" +string(11) "42,42-other" +string(22) "2 147 483 643-other" +string(26) "2 147 483 643,123-other" +string(4) "five" + +ru numeric key +string(8) "42-other" +string(11) "42,42-other" +string(22) "2 147 483 643-other" +string(26) "2 147 483 643,123-other" +string(4) "five" + +==DONE== diff --git a/ext/intl/tests/timezone_IDforWindowsID_basic.phpt b/ext/intl/tests/timezone_IDforWindowsID_basic.phpt new file mode 100644 index 0000000000..4127d8e31c --- /dev/null +++ b/ext/intl/tests/timezone_IDforWindowsID_basic.phpt @@ -0,0 +1,46 @@ +--TEST-- +IntlTimeZone::getIDForWindowsID basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '52') < 0) + die('skip for ICU >= 52'); +--FILE-- +<?php + +$tzs = array( + 'Gnomeregan' => array(NULL), + 'India Standard Time' => array(NULL), + 'Pacific Standard Time' => array('001', 'CA', 'MX', 'US', 'ZZ'), + 'Romance Standard Time' => array('001', 'BE', 'DK', 'ES', 'FR'), +); + +foreach ($tzs as $tz => $regions) { + echo "** $tz\n"; + foreach ($regions as $region) { + var_dump(IntlTimeZone::getIDForWindowsID($tz, $region)); + if (intl_get_error_code() != U_ZERO_ERROR) { + echo "Error: ", intl_get_error_message(), "\n"; + } + } +} + +--EXPECT-- +** Gnomeregan +bool(false) +Error: intltz_get_windows_id: Unknown windows timezone: U_ILLEGAL_ARGUMENT_ERROR +** India Standard Time +string(13) "Asia/Calcutta" +** Pacific Standard Time +string(19) "America/Los_Angeles" +string(17) "America/Vancouver" +string(15) "America/Tijuana" +string(19) "America/Los_Angeles" +string(7) "PST8PDT" +** Romance Standard Time +string(12) "Europe/Paris" +string(15) "Europe/Brussels" +string(17) "Europe/Copenhagen" +string(13) "Europe/Madrid" +string(12) "Europe/Paris" diff --git a/ext/intl/tests/timezone_getCanonicalID_error.phpt b/ext/intl/tests/timezone_getCanonicalID_error.phpt index e268e216a8..b29ca67701 100644 --- a/ext/intl/tests/timezone_getCanonicalID_error.phpt +++ b/ext/intl/tests/timezone_getCanonicalID_error.phpt @@ -11,7 +11,6 @@ ini_set("intl.error_level", E_WARNING); var_dump(IntlTimeZone::getCanonicalID()); var_dump(IntlTimeZone::getCanonicalID(array())); var_dump(IntlTimeZone::getCanonicalID("foo\x81")); -var_dump(IntlTimeZone::getCanonicalID('foobar', null)); --EXPECTF-- @@ -28,8 +27,3 @@ bool(false) Warning: IntlTimeZone::getCanonicalID(): intltz_get_canonical_id: could not convert time zone id to UTF-16 in %s on line %d bool(false) - -Fatal error: Uncaught Error: Cannot pass parameter 2 by reference in %s:%d -Stack trace: -#0 {main} - thrown in %s on line %d diff --git a/ext/intl/tests/timezone_windowsID_basic.phpt b/ext/intl/tests/timezone_windowsID_basic.phpt new file mode 100644 index 0000000000..dd48f016e2 --- /dev/null +++ b/ext/intl/tests/timezone_windowsID_basic.phpt @@ -0,0 +1,43 @@ +--TEST-- +IntlTimeZone::getWindowsID basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '52') < 0) + die('skip for ICU >= 52'); +--FILE-- +<?php + +$tzs = array( + 'America/Bogota', + 'America/Havana', + 'America/Indiana/Knox', + 'America/Los_Angeles', + 'Azeroth/Kalimdor/Durotar', + 'Africa/Casablanca', + 'Asia/Singapore', + 'Australia/Perth', + 'Europe/London', + 'Europe/Istanbul', +); + +foreach ($tzs as $tz) { + var_dump(IntlTimeZone::getWindowsID($tz)); + if (intl_get_error_code() != U_ZERO_ERROR) { + echo "Error: ", intl_get_error_message(), "\n"; + } +} + +--EXPECT-- +string(24) "SA Pacific Standard Time" +string(21) "Eastern Standard Time" +string(21) "Central Standard Time" +string(21) "Pacific Standard Time" +bool(false) +Error: intltz_get_windows_id: Unknown system timezone: U_ILLEGAL_ARGUMENT_ERROR +string(21) "Morocco Standard Time" +string(23) "Singapore Standard Time" +string(26) "W. Australia Standard Time" +string(17) "GMT Standard Time" +string(20) "Turkey Standard Time" |
