Title: [293813] trunk
Revision
293813
Author
ysuz...@apple.com
Date
2022-05-04 19:21:35 -0700 (Wed, 04 May 2022)

Log Message

[JSC] Intl.NumberFormat lacks some validation for rounding-increment
https://bugs.webkit.org/show_bug.cgi?id=240102

Reviewed by Ross Kirsling.

This patch adds some validations added in Intl.NumberFormat v3[1].
Important thing is one is TypeError and one is RangeError.
Both are tested in test262.

[1]: https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-initializenumberformat

* JSTests/test262/expectations.yaml:
* Source/_javascript_Core/runtime/IntlNumberFormat.cpp:
(JSC::IntlNumberFormat::initializeNumberFormat):

Canonical link: https://commits.webkit.org/250286@main

Modified Paths

Diff

Modified: trunk/JSTests/ChangeLog (293812 => 293813)


--- trunk/JSTests/ChangeLog	2022-05-05 01:53:23 UTC (rev 293812)
+++ trunk/JSTests/ChangeLog	2022-05-05 02:21:35 UTC (rev 293813)
@@ -1,3 +1,12 @@
+2022-05-04  Yusuke Suzuki  <ysuz...@apple.com>
+
+        [JSC] Intl.NumberFormat lacks some validation for rounding-increment
+        https://bugs.webkit.org/show_bug.cgi?id=240102
+
+        Reviewed by Ross Kirsling.
+
+        * test262/expectations.yaml:
+
 2022-05-04  Ross Kirsling  <ross.kirsl...@sony.com>
 
         Temporal.Duration constructor should throw on non-integers

Modified: trunk/JSTests/test262/expectations.yaml (293812 => 293813)


--- trunk/JSTests/test262/expectations.yaml	2022-05-05 01:53:23 UTC (rev 293812)
+++ trunk/JSTests/test262/expectations.yaml	2022-05-05 02:21:35 UTC (rev 293813)
@@ -1350,9 +1350,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/constructor-roundingIncrement-invalid.js:
-  default: 'Test262Error: 2, roundingType is "morePrecision" Expected a TypeError but got a RangeError'
-  strict mode: 'Test262Error: 2, roundingType is "morePrecision" Expected a TypeError but got a RangeError'
 test/intl402/NumberFormat/prototype/format/format-rounding-priority-less-precision.js:
   default: 'Test262Error: Formatted value for 1, en-US-u-nu-arab and options {"useGrouping":false,"roundingPriority":"lessPrecision","minimumSignificantDigits":3,"minimumFractionDigits":1} is ١٫٠٠; expected ١٫٠.'
   strict mode: 'Test262Error: Formatted value for 1, en-US-u-nu-arab and options {"useGrouping":false,"roundingPriority":"lessPrecision","minimumSignificantDigits":3,"minimumFractionDigits":1} is ١٫٠٠; expected ١٫٠.'

Modified: trunk/Source/_javascript_Core/ChangeLog (293812 => 293813)


--- trunk/Source/_javascript_Core/ChangeLog	2022-05-05 01:53:23 UTC (rev 293812)
+++ trunk/Source/_javascript_Core/ChangeLog	2022-05-05 02:21:35 UTC (rev 293813)
@@ -1,3 +1,19 @@
+2022-05-04  Yusuke Suzuki  <ysuz...@apple.com>
+
+        [JSC] Intl.NumberFormat lacks some validation for rounding-increment
+        https://bugs.webkit.org/show_bug.cgi?id=240102
+
+        Reviewed by Ross Kirsling.
+
+        This patch adds some validations added in Intl.NumberFormat v3[1].
+        Important thing is one is TypeError and one is RangeError.
+        Both are tested in test262.
+
+        [1]: https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-initializenumberformat
+
+        * runtime/IntlNumberFormat.cpp:
+        (JSC::IntlNumberFormat::initializeNumberFormat):
+
 2022-05-04  Ross Kirsling  <ross.kirsl...@sony.com>
 
         Temporal.Duration constructor should throw on non-integers

Modified: trunk/Source/_javascript_Core/runtime/IntlNumberFormat.cpp (293812 => 293813)


--- trunk/Source/_javascript_Core/runtime/IntlNumberFormat.cpp	2022-05-05 01:53:23 UTC (rev 293812)
+++ trunk/Source/_javascript_Core/runtime/IntlNumberFormat.cpp	2022-05-05 02:21:35 UTC (rev 293813)
@@ -394,9 +394,15 @@
         throwRangeError(globalObject, scope, "roundingIncrement must be one of 1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1000, 2000, 2500, 5000"_s);
         return;
     }
-    if (m_roundingIncrement != 1 && m_roundingType != IntlRoundingType::FractionDigits) {
-        throwRangeError(globalObject, scope, "rounding type is not fraction-digits while roundingIncrement is specified"_s);
-        return;
+    if (m_roundingIncrement != 1) {
+        if (m_roundingType != IntlRoundingType::FractionDigits) {
+            throwTypeError(globalObject, scope, "rounding type is not fraction-digits while roundingIncrement is specified"_s);
+            return;
+        }
+        if (m_maximumFractionDigits != m_minimumFractionDigits) {
+            throwRangeError(globalObject, scope, "maximum and minimum fraction-digits are not equal while roundingIncrement is specified"_s);
+            return;
+        }
     }
 
     m_trailingZeroDisplay = intlOption<TrailingZeroDisplay>(globalObject, options, vm.propertyNames->trailingZeroDisplay, { { "auto"_s, TrailingZeroDisplay::Auto }, { "stripIfInteger"_s, TrailingZeroDisplay::StripIfInteger } }, "trailingZeroDisplay must be either \"auto\" or \"stripIfInteger\""_s, TrailingZeroDisplay::Auto);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to