Title: [263837] trunk
Revision
263837
Author
ysuz...@apple.com
Date
2020-07-02 01:47:57 -0700 (Thu, 02 Jul 2020)

Log Message

[JSC] Configure option-offered numberingSystem in Intl.NumberFormat through locale
https://bugs.webkit.org/show_bug.cgi?id=213872

Reviewed by Ross Kirsling.

JSTests:

* stress/intl-numberformat-nu.js: Added.
(shouldBe):
* test262/expectations.yaml:

Source/_javascript_Core:

We need to pass numberingSystem option to ICU through locale when constructing UNumberFormat.
We are passing it when we get "en-US-u-nu-hanidec" locale, but we are not passing it when
we are getting `new Intl.NumberFormat("en-US", { numberingSystem: "hanidec" })`.

* runtime/IntlNumberFormat.cpp:
(JSC::IntlNumberFormat::initializeNumberFormat):

Modified Paths

Added Paths

Diff

Modified: trunk/JSTests/ChangeLog (263836 => 263837)


--- trunk/JSTests/ChangeLog	2020-07-02 08:20:51 UTC (rev 263836)
+++ trunk/JSTests/ChangeLog	2020-07-02 08:47:57 UTC (rev 263837)
@@ -1,3 +1,14 @@
+2020-07-02  Yusuke Suzuki  <ysuz...@apple.com>
+
+        [JSC] Configure option-offered numberingSystem in Intl.NumberFormat through locale
+        https://bugs.webkit.org/show_bug.cgi?id=213872
+
+        Reviewed by Ross Kirsling.
+
+        * stress/intl-numberformat-nu.js: Added.
+        (shouldBe):
+        * test262/expectations.yaml:
+
 2020-07-01  Yusuke Suzuki  <ysuz...@apple.com>
 
         [JSC] Intl.Collator should set usage:"search" option through ICU locale

Added: trunk/JSTests/stress/intl-numberformat-nu.js (0 => 263837)


--- trunk/JSTests/stress/intl-numberformat-nu.js	                        (rev 0)
+++ trunk/JSTests/stress/intl-numberformat-nu.js	2020-07-02 08:47:57 UTC (rev 263837)
@@ -0,0 +1,16 @@
+function shouldBe(actual, expected) {
+    if (actual !== expected)
+        throw new Error('bad value: ' + actual);
+}
+
+shouldBe(new Intl.NumberFormat(`en-US-u-nu-hanidec`).resolvedOptions().locale, `en-US-u-nu-hanidec`);
+shouldBe(new Intl.NumberFormat(`en-US`, { numberingSystem: "hanidec" }).resolvedOptions().locale, `en-US`);
+shouldBe(new Intl.NumberFormat(`en-US-u-nu-hanidec`, { numberingSystem: 'latn' }).resolvedOptions().locale, `en-US`);
+shouldBe(new Intl.NumberFormat(`en-US-u-nu-latn`, { numberingSystem: 'hanidec' }).resolvedOptions().locale, `en-US`);
+shouldBe(new Intl.NumberFormat(`en-US-u-nu-adlm`, { numberingSystem: 'hanidec' }).resolvedOptions().locale, `en-US`);
+
+shouldBe(new Intl.NumberFormat(`en-US-u-nu-hanidec`).format(20), `二〇`);
+shouldBe(new Intl.NumberFormat(`en-US`, { numberingSystem: "hanidec" }).format(20), `二〇`);
+shouldBe(new Intl.NumberFormat(`en-US-u-nu-hanidec`, { numberingSystem: 'latn' }).format(20), `20`);
+shouldBe(new Intl.NumberFormat(`en-US-u-nu-latn`, { numberingSystem: 'hanidec' }).format(20), `二〇`);
+shouldBe(new Intl.NumberFormat(`en-US-u-nu-adlm`, { numberingSystem: 'hanidec' }).format(20), `二〇`);

Modified: trunk/JSTests/test262/expectations.yaml (263836 => 263837)


--- trunk/JSTests/test262/expectations.yaml	2020-07-02 08:20:51 UTC (rev 263836)
+++ trunk/JSTests/test262/expectations.yaml	2020-07-02 08:47:57 UTC (rev 263837)
@@ -1701,9 +1701,6 @@
 test/intl402/Locale/prototype/minimize/removing-likely-subtags-first-adds-likely-subtags.js:
   default: 'Test262Error: "und".minimize() should be "en" Expected SameValue(«en-u-va-posix», «en») to be true'
   strict mode: 'Test262Error: "und".minimize() should be "en" Expected SameValue(«en-u-va-posix», «en») to be true'
-test/intl402/NumberFormat/prototype/format/numbering-systems.js:
-  default: 'Test262Error: numberingSystem: adlm, digit: 0 Expected SameValue(«0», «𞥐») to be true'
-  strict mode: 'Test262Error: numberingSystem: adlm, digit: 0 Expected SameValue(«0», «𞥐») to be true'
 test/intl402/RelativeTimeFormat/constructor/constructor/locales-valid.js:
   default: 'Test262Error: Grandfathered Expected a RangeError to be thrown but no exception was thrown at all'
   strict mode: 'Test262Error: Grandfathered Expected a RangeError to be thrown but no exception was thrown at all'

Modified: trunk/Source/_javascript_Core/ChangeLog (263836 => 263837)


--- trunk/Source/_javascript_Core/ChangeLog	2020-07-02 08:20:51 UTC (rev 263836)
+++ trunk/Source/_javascript_Core/ChangeLog	2020-07-02 08:47:57 UTC (rev 263837)
@@ -1,3 +1,17 @@
+2020-07-02  Yusuke Suzuki  <ysuz...@apple.com>
+
+        [JSC] Configure option-offered numberingSystem in Intl.NumberFormat through locale
+        https://bugs.webkit.org/show_bug.cgi?id=213872
+
+        Reviewed by Ross Kirsling.
+
+        We need to pass numberingSystem option to ICU through locale when constructing UNumberFormat.
+        We are passing it when we get "en-US-u-nu-hanidec" locale, but we are not passing it when
+        we are getting `new Intl.NumberFormat("en-US", { numberingSystem: "hanidec" })`.
+
+        * runtime/IntlNumberFormat.cpp:
+        (JSC::IntlNumberFormat::initializeNumberFormat):
+
 2020-07-01  Yusuke Suzuki  <ysuz...@apple.com>
 
         [JSC] Intl.Collator should set usage:"search" option through ICU locale

Modified: trunk/Source/_javascript_Core/runtime/IntlNumberFormat.cpp (263836 => 263837)


--- trunk/Source/_javascript_Core/runtime/IntlNumberFormat.cpp	2020-07-02 08:20:51 UTC (rev 263836)
+++ trunk/Source/_javascript_Core/runtime/IntlNumberFormat.cpp	2020-07-02 08:47:57 UTC (rev 263837)
@@ -42,6 +42,7 @@
 
 namespace IntlNumberFormatInternal {
 constexpr const char* relevantExtensionKeys[1] = { "nu" };
+constexpr bool verbose = false;
 }
 
 struct IntlNumberFormatField {
@@ -310,8 +311,11 @@
         ASSERT_NOT_REACHED();
     }
 
+    CString dataLocaleWithExtensions = makeString(result.get("dataLocale"_s), "-u-nu-", m_numberingSystem).utf8();
+    dataLogLnIf(IntlNumberFormatInternal::verbose, "dataLocaleWithExtensions:(", dataLocaleWithExtensions , ")");
+
     UErrorCode status = U_ZERO_ERROR;
-    m_numberFormat = std::unique_ptr<UNumberFormat, UNumberFormatDeleter>(unum_open(style, nullptr, 0, m_locale.utf8().data(), nullptr, &status));
+    m_numberFormat = std::unique_ptr<UNumberFormat, UNumberFormatDeleter>(unum_open(style, nullptr, 0, dataLocaleWithExtensions.data(), nullptr, &status));
     if (U_FAILURE(status)) {
         throwTypeError(globalObject, scope, "failed to initialize NumberFormat"_s);
         return;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to