Title: [215679] trunk
Revision
215679
Author
commit-qu...@webkit.org
Date
2017-04-23 14:19:11 -0700 (Sun, 23 Apr 2017)

Log Message

test262: test262/test/built-ins/Number/prototype/toPrecision/nan.js
https://bugs.webkit.org/show_bug.cgi?id=171197

Patch by Joseph Pecoraro <pecor...@apple.com> on 2017-04-23
Reviewed by Saam Barati.

JSTests:

* test262.yaml:

Source/_javascript_Core:

* runtime/NumberPrototype.cpp:
(JSC::numberProtoFuncToExponential):
(JSC::numberProtoFuncToFixed):
(JSC::numberProtoFuncToPrecision):
Refine the order of operations to match the spec.

Modified Paths

Diff

Modified: trunk/JSTests/ChangeLog (215678 => 215679)


--- trunk/JSTests/ChangeLog	2017-04-23 20:47:13 UTC (rev 215678)
+++ trunk/JSTests/ChangeLog	2017-04-23 21:19:11 UTC (rev 215679)
@@ -1,5 +1,14 @@
 2017-04-23  Joseph Pecoraro  <pecor...@apple.com>
 
+        test262: test262/test/built-ins/Number/prototype/toPrecision/nan.js
+        https://bugs.webkit.org/show_bug.cgi?id=171197
+
+        Reviewed by Saam Barati.
+
+        * test262.yaml:
+
+2017-04-23  Joseph Pecoraro  <pecor...@apple.com>
+
         test262: test262/test/language/expressions/generators/yield-as-label.js
         https://bugs.webkit.org/show_bug.cgi?id=170979
 

Modified: trunk/JSTests/test262.yaml (215678 => 215679)


--- trunk/JSTests/test262.yaml	2017-04-23 20:47:13 UTC (rev 215678)
+++ trunk/JSTests/test262.yaml	2017-04-23 21:19:11 UTC (rev 215679)
@@ -22026,9 +22026,9 @@
 - path: test262/test/built-ins/Number/prototype/prop-desc.js
   cmd: runTest262 :normal, "NoException", ["../../../../harness/assert.js", "../../../../harness/sta.js", "../../../../harness/propertyHelper.js"], [:strict]
 - path: test262/test/built-ins/Number/prototype/toExponential/infinity.js
-  cmd: runTest262 :fail, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], []
+  cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], []
 - path: test262/test/built-ins/Number/prototype/toExponential/infinity.js
-  cmd: runTest262 :fail, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], [:strict]
+  cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], [:strict]
 - path: test262/test/built-ins/Number/prototype/toExponential/length.js
   cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js", "../../../../../harness/propertyHelper.js"], []
 - path: test262/test/built-ins/Number/prototype/toExponential/length.js
@@ -22038,9 +22038,9 @@
 - path: test262/test/built-ins/Number/prototype/toExponential/name.js
   cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js", "../../../../../harness/propertyHelper.js"], [:strict]
 - path: test262/test/built-ins/Number/prototype/toExponential/nan.js
-  cmd: runTest262 :fail, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], []
+  cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], []
 - path: test262/test/built-ins/Number/prototype/toExponential/nan.js
-  cmd: runTest262 :fail, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], [:strict]
+  cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], [:strict]
 - path: test262/test/built-ins/Number/prototype/toExponential/prop-desc.js
   cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js", "../../../../../harness/propertyHelper.js"], []
 - path: test262/test/built-ins/Number/prototype/toExponential/prop-desc.js
@@ -22126,9 +22126,9 @@
 - path: test262/test/built-ins/Number/prototype/toPrecision/exponential.js
   cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], [:strict]
 - path: test262/test/built-ins/Number/prototype/toPrecision/infinity.js
-  cmd: runTest262 :fail, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], []
+  cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], []
 - path: test262/test/built-ins/Number/prototype/toPrecision/infinity.js
-  cmd: runTest262 :fail, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], [:strict]
+  cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], [:strict]
 - path: test262/test/built-ins/Number/prototype/toPrecision/length.js
   cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js", "../../../../../harness/propertyHelper.js"], []
 - path: test262/test/built-ins/Number/prototype/toPrecision/length.js
@@ -22138,21 +22138,21 @@
 - path: test262/test/built-ins/Number/prototype/toPrecision/name.js
   cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js", "../../../../../harness/propertyHelper.js"], [:strict]
 - path: test262/test/built-ins/Number/prototype/toPrecision/nan.js
-  cmd: runTest262 :fail, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], []
+  cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], []
 - path: test262/test/built-ins/Number/prototype/toPrecision/nan.js
-  cmd: runTest262 :fail, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], [:strict]
+  cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], [:strict]
 - path: test262/test/built-ins/Number/prototype/toPrecision/prop-desc.js
   cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js", "../../../../../harness/propertyHelper.js"], []
 - path: test262/test/built-ins/Number/prototype/toPrecision/prop-desc.js
   cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js", "../../../../../harness/propertyHelper.js"], [:strict]
 - path: test262/test/built-ins/Number/prototype/toPrecision/return-abrupt-tointeger-precision-symbol.js
-  cmd: runTest262 :fail, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], []
+  cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], []
 - path: test262/test/built-ins/Number/prototype/toPrecision/return-abrupt-tointeger-precision-symbol.js
-  cmd: runTest262 :fail, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], [:strict]
+  cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], [:strict]
 - path: test262/test/built-ins/Number/prototype/toPrecision/return-abrupt-tointeger-precision.js
-  cmd: runTest262 :fail, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], []
+  cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], []
 - path: test262/test/built-ins/Number/prototype/toPrecision/return-abrupt-tointeger-precision.js
-  cmd: runTest262 :fail, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], [:strict]
+  cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], [:strict]
 - path: test262/test/built-ins/Number/prototype/toPrecision/return-values.js
   cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], []
 - path: test262/test/built-ins/Number/prototype/toPrecision/return-values.js

Modified: trunk/Source/_javascript_Core/ChangeLog (215678 => 215679)


--- trunk/Source/_javascript_Core/ChangeLog	2017-04-23 20:47:13 UTC (rev 215678)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-04-23 21:19:11 UTC (rev 215679)
@@ -1,5 +1,18 @@
 2017-04-23  Joseph Pecoraro  <pecor...@apple.com>
 
+        test262: test262/test/built-ins/Number/prototype/toPrecision/nan.js
+        https://bugs.webkit.org/show_bug.cgi?id=171197
+
+        Reviewed by Saam Barati.
+
+        * runtime/NumberPrototype.cpp:
+        (JSC::numberProtoFuncToExponential):
+        (JSC::numberProtoFuncToFixed):
+        (JSC::numberProtoFuncToPrecision):
+        Refine the order of operations to match the spec.
+
+2017-04-23  Joseph Pecoraro  <pecor...@apple.com>
+
         test262: test262/test/language/expressions/generators/yield-as-label.js
         https://bugs.webkit.org/show_bug.cgi?id=170979
 

Modified: trunk/Source/_javascript_Core/runtime/NumberPrototype.cpp (215678 => 215679)


--- trunk/Source/_javascript_Core/runtime/NumberPrototype.cpp	2017-04-23 20:47:13 UTC (rev 215678)
+++ trunk/Source/_javascript_Core/runtime/NumberPrototype.cpp	2017-04-23 21:19:11 UTC (rev 215679)
@@ -384,7 +384,7 @@
     return String(p, static_cast<unsigned>(end - p));
 }
 
-// toExponential converts a number to a string, always formatting as an expoential.
+// toExponential converts a number to a string, always formatting as an exponential.
 // This method takes an optional argument specifying a number of *decimal places*
 // to round the significand to (or, put another way, this method optionally rounds
 // to argument-plus-one significant figures).
@@ -397,16 +397,19 @@
     if (!toThisNumber(exec->thisValue(), x))
         return throwVMTypeError(exec, scope);
 
-    // Get the argument. 
+    // Perform ToInteger on the argument before remaining steps.
     int decimalPlacesInExponent;
     bool isUndefined;
-    if (!getIntegerArgumentInRange(exec, 0, 20, decimalPlacesInExponent, isUndefined))
-        return throwVMError(exec, scope, createRangeError(exec, ASCIILiteral("toExponential() argument must be between 0 and 20")));
+    bool inRange = getIntegerArgumentInRange(exec, 0, 20, decimalPlacesInExponent, isUndefined);
+    RETURN_IF_EXCEPTION(scope, { });
 
     // Handle NaN and Infinity.
     if (!std::isfinite(x))
         return JSValue::encode(jsNontrivialString(exec, String::numberToStringECMAScript(x)));
 
+    if (!inRange)
+        return throwVMError(exec, scope, createRangeError(exec, ASCIILiteral("toExponential() argument must be between 0 and 20")));
+
     // Round if the argument is not undefined, always format as exponential.
     char buffer[WTF::NumberToStringBufferLength];
     DoubleConversionStringBuilder builder(buffer, WTF::NumberToStringBufferLength);
@@ -434,7 +437,9 @@
     // Get the argument. 
     int decimalPlaces;
     bool isUndefined; // This is ignored; undefined treated as 0.
-    if (!getIntegerArgumentInRange(exec, 0, 20, decimalPlaces, isUndefined))
+    bool inRange = getIntegerArgumentInRange(exec, 0, 20, decimalPlaces, isUndefined);
+    RETURN_IF_EXCEPTION(scope, { });
+    if (!inRange)
         return throwVMError(exec, scope, createRangeError(exec, ASCIILiteral("toFixed() argument must be between 0 and 20")));
 
     // 15.7.4.5.7 states "If x >= 10^21, then let m = ToString(x)"
@@ -451,7 +456,7 @@
     return JSValue::encode(jsString(exec, String(numberToFixedWidthString(x, decimalPlaces, buffer))));
 }
 
-// toPrecision converts a number to a string, takeing an argument specifying a
+// toPrecision converts a number to a string, taking an argument specifying a
 // number of significant figures to round the significand to. For positive
 // exponent, all values that can be represented using a decimal fraction will
 // be, e.g. when rounding to 3 s.f. any value up to 999 will be formated as a
@@ -467,11 +472,11 @@
     if (!toThisNumber(exec->thisValue(), x))
         return throwVMTypeError(exec, scope);
 
-    // Get the argument. 
+    // Perform ToInteger on the argument before remaining steps.
     int significantFigures;
     bool isUndefined;
-    if (!getIntegerArgumentInRange(exec, 1, 21, significantFigures, isUndefined))
-        return throwVMError(exec, scope, createRangeError(exec, ASCIILiteral("toPrecision() argument must be between 1 and 21")));
+    bool inRange = getIntegerArgumentInRange(exec, 1, 21, significantFigures, isUndefined);
+    RETURN_IF_EXCEPTION(scope, { });
 
     // To precision called with no argument is treated as ToString.
     if (isUndefined)
@@ -481,6 +486,9 @@
     if (!std::isfinite(x))
         return JSValue::encode(jsNontrivialString(exec, String::numberToStringECMAScript(x)));
 
+    if (!inRange)
+        return throwVMError(exec, scope, createRangeError(exec, ASCIILiteral("toPrecision() argument must be between 1 and 21")));
+
     NumberToStringBuffer buffer;
     return JSValue::encode(jsString(exec, String(numberToFixedPrecisionString(x, significantFigures, buffer))));
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to