summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2018-06-25 11:30:14 +0200
committerAnatol Belski <ab@php.net>2018-06-25 11:30:14 +0200
commit5af0db88fafe7b36d13c67bc641e0f3749e59d7d (patch)
tree177cc22cb9c63971cd2fbcce8324d7fb6128e56d
parent701460ba84865be03df81265a6c6d76f40dd6b00 (diff)
downloadphp-git-5af0db88fafe7b36d13c67bc641e0f3749e59d7d.tar.gz
Prepare tests for ICU 62.1
-rw-r--r--ext/intl/tests/bug62070_2.phpt1
-rw-r--r--ext/intl/tests/bug62070_3.phpt15
-rw-r--r--ext/intl/tests/collator_get_sort_key_variant6.phpt1
-rw-r--r--ext/intl/tests/collator_get_sort_key_variant7.phpt98
-rw-r--r--ext/intl/tests/formatter_format7.phpt3
-rw-r--r--ext/intl/tests/formatter_format8.phpt130
-rw-r--r--ext/intl/tests/formatter_format_currency2.phpt4
-rw-r--r--ext/intl/tests/formatter_get_locale_variant3.phpt1
-rw-r--r--ext/intl/tests/formatter_get_locale_variant4.phpt50
-rw-r--r--ext/intl/tests/formatter_get_set_pattern.phpt1
-rw-r--r--ext/intl/tests/formatter_get_set_pattern2.phpt53
-rw-r--r--ext/intl/tests/formatter_get_set_symbol2.phpt4
12 files changed, 356 insertions, 5 deletions
diff --git a/ext/intl/tests/bug62070_2.phpt b/ext/intl/tests/bug62070_2.phpt
index 63f510793b..c632b569cc 100644
--- a/ext/intl/tests/bug62070_2.phpt
+++ b/ext/intl/tests/bug62070_2.phpt
@@ -3,6 +3,7 @@ Bug #62070: Collator::getSortKey() returns garbage
--SKIPIF--
<?php if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '53.1') < 0) die('skip for ICU >= 53.1'); ?>
+<?php if (version_compare(INTL_ICU_VERSION, '62.1') >= 0) die('skip for ICU < 62.1'); ?>
--FILE--
<?php
$s1 = 'Hello';
diff --git a/ext/intl/tests/bug62070_3.phpt b/ext/intl/tests/bug62070_3.phpt
new file mode 100644
index 0000000000..5510798b6b
--- /dev/null
+++ b/ext/intl/tests/bug62070_3.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Bug #62070: Collator::getSortKey() returns garbage
+--SKIPIF--
+<?php if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
+<?php if (version_compare(INTL_ICU_VERSION, '62.1') < 0) die('skip for ICU >= 62.1'); ?>
+--FILE--
+<?php
+$s1 = 'Hello';
+
+$coll = collator_create('en_US');
+$res = collator_get_sort_key($coll, $s1);
+
+echo urlencode($res);
+--EXPECT--
+82%40%40F%01%09%01%DC%08
diff --git a/ext/intl/tests/collator_get_sort_key_variant6.phpt b/ext/intl/tests/collator_get_sort_key_variant6.phpt
index d8105d76d4..78c74f546a 100644
--- a/ext/intl/tests/collator_get_sort_key_variant6.phpt
+++ b/ext/intl/tests/collator_get_sort_key_variant6.phpt
@@ -3,6 +3,7 @@ collator_get_sort_key() icu >= 56.1
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
<?php if (version_compare(INTL_ICU_VERSION, '56.1') < 0) die('skip for ICU >= 56.1'); ?>
+<?php if (version_compare(INTL_ICU_VERSION, '62.1') >= 0) die('skip for ICU < 62.1'); ?>
--FILE--
<?php
diff --git a/ext/intl/tests/collator_get_sort_key_variant7.phpt b/ext/intl/tests/collator_get_sort_key_variant7.phpt
new file mode 100644
index 0000000000..e009d0e663
--- /dev/null
+++ b/ext/intl/tests/collator_get_sort_key_variant7.phpt
@@ -0,0 +1,98 @@
+--TEST--
+collator_get_sort_key() icu >= 62.1
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+<?php if (version_compare(INTL_ICU_VERSION, '62.1') < 0) die('skip for ICU >= 62.1'); ?>
+--FILE--
+<?php
+
+/*
+ * Get sort keys using various locales
+ */
+function sort_arrays( $locale, $data )
+{
+ $res_str = '';
+
+ $coll = ut_coll_create( $locale );
+
+ foreach($data as $value) {
+ $res_val = ut_coll_get_sort_key( $coll, $value );
+ $res_str .= "source: ".$value."\n".
+ "key: ".bin2hex($res_val)."\n";
+ }
+
+ return $res_str;
+}
+
+
+function ut_main()
+{
+ $res_str = '';
+
+ // Regular strings keys
+ $test_params = array(
+ 'abc', 'abd', 'aaa',
+ 'аа', 'а', 'z',
+ '', null , '3',
+ 'y' , 'i' , 'k'
+ );
+
+ $res_str .= sort_arrays( 'en_US', $test_params );
+
+ // Sort a non-ASCII array using ru_RU locale.
+ $test_params = array(
+ 'абг', 'абв', 'жжж', 'эюя'
+ );
+
+ $res_str .= sort_arrays( 'ru_RU', $test_params );
+
+ // Sort an array using Lithuanian locale.
+ $res_str .= sort_arrays( 'lt_LT', $test_params );
+
+ return $res_str . "\n";
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+?>
+--EXPECT--
+source: abc
+key: 2a2c2e01070107
+source: abd
+key: 2a2c3001070107
+source: aaa
+key: 2a2a2a01070107
+source: аа
+key: 61060601060106
+source: а
+key: 610601050105
+source: z
+key: 5c01050105
+source:
+key: 0101
+source:
+key: 0101
+source: 3
+key: 1901050105
+source: y
+key: 5a01050105
+source: i
+key: 3a01050105
+source: k
+key: 3e01050105
+source: абг
+key: 27060c1001070107
+source: абв
+key: 27060c0e01070107
+source: жжж
+key: 272c2c2c01070107
+source: эюя
+key: 27eef0f401070107
+source: абг
+key: 61060c1001070107
+source: абв
+key: 61060c0e01070107
+source: жжж
+key: 612c2c2c01070107
+source: эюя
+key: 61eef0f401070107
diff --git a/ext/intl/tests/formatter_format7.phpt b/ext/intl/tests/formatter_format7.phpt
index 088c526c70..13d58bdd51 100644
--- a/ext/intl/tests/formatter_format7.phpt
+++ b/ext/intl/tests/formatter_format7.phpt
@@ -1,8 +1,9 @@
--TEST--
-numfmt_format() icu >= 61.1
+numfmt_format() icu >= 61.1 && < 62.1
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
<?php if (version_compare(INTL_ICU_VERSION, '61.1') < 0) die('skip for ICU >= 61.1'); ?>
+<?php if (version_compare(INTL_ICU_VERSION, '62.1') >= 0) die('skip for ICU < 62.1'); ?>
--FILE--
<?php
diff --git a/ext/intl/tests/formatter_format8.phpt b/ext/intl/tests/formatter_format8.phpt
new file mode 100644
index 0000000000..55b10ffdfc
--- /dev/null
+++ b/ext/intl/tests/formatter_format8.phpt
@@ -0,0 +1,130 @@
+--TEST--
+numfmt_format() icu >= 62.1
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+<?php if (version_compare(INTL_ICU_VERSION, '62.1') < 0) die('skip for ICU >= 62.1'); ?>
+--FILE--
+<?php
+
+/*
+ * Format a number using misc locales/patterns.
+ */
+
+/*
+ * TODO: doesn't pass on ICU 3.6 because 'ru' and 'de' locales changed
+ * currency and percent formatting.
+ */
+
+function ut_main()
+{
+ $styles = array(
+ NumberFormatter::PATTERN_DECIMAL => '##.#####################',
+ NumberFormatter::DECIMAL => '',
+ NumberFormatter::CURRENCY => '',
+ NumberFormatter::PERCENT => '',
+ NumberFormatter::SCIENTIFIC => '',
+ NumberFormatter::SPELLOUT => '@@@@@@@',
+ NumberFormatter::ORDINAL => '',
+ NumberFormatter::DURATION => '',
+ NumberFormatter::PATTERN_RULEBASED => '#####.###',
+ 1234999, // bad one
+ );
+
+ $integer = array(
+ NumberFormatter::ORDINAL => '',
+ NumberFormatter::DURATION => '',
+ );
+ $locales = array(
+ 'en_US',
+ 'ru_UA',
+ 'de',
+ 'fr',
+ 'en_UK'
+ );
+
+ $str_res = '';
+ $number = 1234567.891234567890000;
+
+ foreach( $locales as $locale )
+ {
+ $str_res .= "\nLocale is: $locale\n";
+ foreach( $styles as $style => $pattern )
+ {
+ $fmt = ut_nfmt_create( $locale, $style, $pattern );
+
+ if(!$fmt) {
+ $str_res .= "Bad formatter!\n";
+ continue;
+ }
+ $str_res .= dump( isset($integer[$style])?ut_nfmt_format( $fmt, $number, NumberFormatter::TYPE_INT32):ut_nfmt_format( $fmt, $number ) ) . "\n";
+ }
+ }
+ return $str_res;
+}
+
+include_once( 'ut_common.inc' );
+
+// Run the test
+ut_run();
+
+?>
+--EXPECTREGEX--
+Locale is: en_US
+'1234567.8912345\d+'
+'1,234,567.891'
+'\$1,234,567.89'
+'123,456,789%'
+'1.2345678912345\d+E6'
+'one million,? two hundred (and )?thirty-four thousand,? five hundred (and )?sixty-seven point eight nine one two three four five( six)? seven( nine)?'
+'1,234,567(th|ᵗʰ)'
+'342:56:07'
+'#####.###'
+'USD 1,234,567.89'
+
+Locale is: ru_UA
+'1234567.8912345\d+'
+'1 234 567,891'
+'1 234 567,89 ?(грн\.|₴)'
+'123 456 789 ?%'
+'1.2345678912345\d+E6'
+'один миллион двести тридцать четыре тысячи пятьсот шестьдесят семь целых восемьдесят девять миллионов сто двадцать три тысячи четыреста пятьдесят семь стомиллионных'
+'1 234 567.?'
+'1 234 567'
+'#####.###'
+'1 234 567,89 UAH'
+
+Locale is: de
+'1234567.8912345\d+'
+'1.234.567,891'
+'1.234.567,89 XXX'
+'123\.456\.789 %'
+'1.2345678912345\d+E6'
+'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)?'
+'1.234.567.?'
+'1.234.567'
+'#####.###'
+'1.234.567,89 XXX'
+
+Locale is: fr
+'1234567.8912345\d+'
+'1 234 567,891'
+'1 234 567,89 XXX'
+'123 456 789 ?%'
+'1.2345678912345\d+E6'
+'un million deux cent trente-quatre mille cinq cent soixante-sept virgule huit neuf un deux trois quatre cinq( six)? sept( neuf)?'
+'1 234 567e'
+'1 234 567'
+'#####.###'
+'1 234 567,89 XXX'
+
+Locale is: en_UK
+'1234567.8912345\d+'
+'1,234,567.891'
+'XXX 1,234,567.89'
+'123,456,789%'
+'1.2345678912345\d+E6'
+'one million,? two hundred (and )?thirty-four thousand,? five hundred (and )?sixty-seven point eight nine one two three four five( six)? seven( nine)?'
+'1,234,567(th|ᵗʰ)'
+'342:56:07'
+'#####.###'
+'XXX 1,234,567.89'
diff --git a/ext/intl/tests/formatter_format_currency2.phpt b/ext/intl/tests/formatter_format_currency2.phpt
index d9277f3e98..16a421018c 100644
--- a/ext/intl/tests/formatter_format_currency2.phpt
+++ b/ext/intl/tests/formatter_format_currency2.phpt
@@ -42,9 +42,9 @@ include_once( 'ut_common.inc' );
ut_run();
?>
---EXPECT--
+--EXPECTF--
en_UK: '£1,234,567.89'
en_US: '$1,234,567.89'
ru: '1 234 567,89 р.'
uk: '1 234 567,89 ₴'
-en: 'UAH1,234,567.89'
+en: 'UAH%A1,234,567.89'
diff --git a/ext/intl/tests/formatter_get_locale_variant3.phpt b/ext/intl/tests/formatter_get_locale_variant3.phpt
index 901e2353b4..8f3ea8edc7 100644
--- a/ext/intl/tests/formatter_get_locale_variant3.phpt
+++ b/ext/intl/tests/formatter_get_locale_variant3.phpt
@@ -3,6 +3,7 @@ numfmt_get_locale()
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
<?php if (version_compare(INTL_ICU_VERSION, '58.1') < 0) die('skip for ICU >= 58.1'); ?>
+<?php if (version_compare(INTL_ICU_VERSION, '62.1') >= 0) die('skip for ICU < 62.1'); ?>
--FILE--
<?php
diff --git a/ext/intl/tests/formatter_get_locale_variant4.phpt b/ext/intl/tests/formatter_get_locale_variant4.phpt
new file mode 100644
index 0000000000..a37c271dca
--- /dev/null
+++ b/ext/intl/tests/formatter_get_locale_variant4.phpt
@@ -0,0 +1,50 @@
+--TEST--
+numfmt_get_locale()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+<?php if (version_compare(INTL_ICU_VERSION, '62.1') < 0) die('skip for ICU >= 62.1'); ?>
+--FILE--
+<?php
+
+/*
+ * Get locale.
+ */
+
+function ut_main()
+{
+ $locales = array(
+ 'en_UK',
+ 'en_US',
+ 'fr_CA',
+ );
+
+ $loc_types = array(
+ Locale::ACTUAL_LOCALE => 'actual',
+ Locale::VALID_LOCALE => 'valid',
+ );
+
+ $res_str = '';
+
+ foreach( $locales as $locale )
+ {
+ $fmt = ut_nfmt_create( $locale, NumberFormatter::DECIMAL );
+ $res_str .= "$locale: ";
+ foreach( $loc_types as $loc_type => $loc_type_name )
+ $res_str .= sprintf( " %s=%s",
+ $loc_type_name,
+ dump( ut_nfmt_get_locale( $fmt, $loc_type ) ) );
+ $res_str .= "\n";
+ }
+
+ return $res_str;
+}
+
+include_once( 'ut_common.inc' );
+
+// Run the test
+ut_run();
+?>
+--EXPECT--
+en_UK: actual='en' valid='en'
+en_US: actual='en_US' valid='en_US'
+fr_CA: actual='fr_CA' valid='fr_CA'
diff --git a/ext/intl/tests/formatter_get_set_pattern.phpt b/ext/intl/tests/formatter_get_set_pattern.phpt
index 0ae5b308b2..7f33254e2c 100644
--- a/ext/intl/tests/formatter_get_set_pattern.phpt
+++ b/ext/intl/tests/formatter_get_set_pattern.phpt
@@ -2,6 +2,7 @@
numfmt_get/set_pattern()
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+<?php if (version_compare(INTL_ICU_VERSION, '62.1') >= 0) die('skip for ICU < 62.1'); ?>
--FILE--
<?php
diff --git a/ext/intl/tests/formatter_get_set_pattern2.phpt b/ext/intl/tests/formatter_get_set_pattern2.phpt
new file mode 100644
index 0000000000..7bf98ae79e
--- /dev/null
+++ b/ext/intl/tests/formatter_get_set_pattern2.phpt
@@ -0,0 +1,53 @@
+--TEST--
+numfmt_get/set_pattern()
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+<?php if (version_compare(INTL_ICU_VERSION, '62.1') < 0) die('skip for ICU >= 62.1'); ?>
+--FILE--
+<?php
+
+/*
+ * Get/set pattern.
+ */
+
+
+function ut_main()
+{
+ $res_str = '';
+ $test_value = 12345.123456;
+ $fmt = ut_nfmt_create( "en_US", NumberFormatter::PATTERN_DECIMAL );
+
+ // Get default patten.
+ $res_str .= "Default pattern: '" . ut_nfmt_get_pattern( $fmt ) . "'\n";
+ $res_str .= "Formatting result: " . ut_nfmt_format( $fmt, $test_value ) . "\n";
+
+ // Set a new pattern.
+ $res = ut_nfmt_set_pattern( $fmt, "0.0" );
+ if( $res === false )
+ $res_str .= ut_nfmt_get_error_message( $fmt ) . " (" . ut_nfmt_get_error_code( $fmt ) . ")\n";
+
+ // Check if the pattern has been changed.
+ $res = ut_nfmt_get_pattern( $fmt );
+ if( $res === false )
+ $res_str .= ut_nfmt_get_error_message( $fmt ) . " (" . ut_nfmt_get_error_code( $fmt ) . ")\n";
+ $res_str .= "New pattern: '" . ut_nfmt_get_pattern( $fmt ) . "'\n";
+ $res_str .= "Formatted number: " . ut_nfmt_format( $fmt, $test_value ) . "\n";
+
+ ut_nfmt_set_pattern($fmt, str_repeat('@', 200));
+ $res_str .= "New pattern: '" . ut_nfmt_get_pattern( $fmt ) . "'\n";
+ $res_str .= "Formatted number: " . ut_nfmt_format( $fmt, $test_value ) . "\n";
+
+ return $res_str;
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECT--
+Default pattern: '#'
+Formatting result: 12345.123456
+New pattern: '0.0'
+Formatted number: 12345.1
+New pattern: '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'
+Formatted number: 12345.123456000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
diff --git a/ext/intl/tests/formatter_get_set_symbol2.phpt b/ext/intl/tests/formatter_get_set_symbol2.phpt
index 3f982cd063..8e762f350f 100644
--- a/ext/intl/tests/formatter_get_set_symbol2.phpt
+++ b/ext/intl/tests/formatter_get_set_symbol2.phpt
@@ -88,7 +88,7 @@ include_once( 'ut_common.inc' );
ut_run();
?>
---EXPECT--
+--EXPECTF--
Symbol 'DECIMAL_SEPARATOR_SYMBOL'
Default symbol: [.]
New symbol: [_._]
@@ -132,7 +132,7 @@ A number formatted with the new symbol: 1.2345123456E4
Symbol 'CURRENCY_SYMBOL'
Default symbol: [$]
New symbol: [_$_]
-A number formatted with the new symbol: _$_12,345.12
+A number formatted with the new symbol: _$_%A12,345.12
Symbol 'INTL_CURRENCY_SYMBOL'
Default symbol: [USD]