Diff
Modified: trunk/JSTests/ChakraCore/test/Number/toString_3.baseline-jsc (250388 => 250389)
--- trunk/JSTests/ChakraCore/test/Number/toString_3.baseline-jsc 2019-09-26 18:04:31 UTC (rev 250388)
+++ trunk/JSTests/ChakraCore/test/Number/toString_3.baseline-jsc 2019-09-26 18:17:52 UTC (rev 250389)
@@ -10,8 +10,7 @@
n.toFixed(2): 444123.00
n.toFixed(5): 444123.00000
n.toFixed(20): 444123.00000000000000000000
-RangeError: toFixed() argument must be between 0 and 20
-RangeError: toFixed() argument must be between 0 and 20
+RangeError: toFixed() argument must be between 0 and 100
n.toExponential(): 4.44123e+5
n.toExponential(2): 4.44e+5
n.toExponential(5): 4.44123e+5
@@ -32,8 +31,7 @@
n.toFixed(2): -444123.00
n.toFixed(5): -444123.00000
n.toFixed(20): -444123.00000000000000000000
-RangeError: toFixed() argument must be between 0 and 20
-RangeError: toFixed() argument must be between 0 and 20
+RangeError: toFixed() argument must be between 0 and 100
n.toExponential(): -4.44123e+5
n.toExponential(2): -4.44e+5
n.toExponential(5): -4.44123e+5
@@ -54,8 +52,7 @@
n.toFixed(2): 444123.79
n.toFixed(5): 444123.78912
n.toFixed(20): 444123.78912345680873841047
-RangeError: toFixed() argument must be between 0 and 20
-RangeError: toFixed() argument must be between 0 and 20
+RangeError: toFixed() argument must be between 0 and 100
n.toExponential(): 4.441237891234568e+5
n.toExponential(2): 4.44e+5
n.toExponential(5): 4.44124e+5
@@ -76,8 +73,7 @@
n.toFixed(2): -444123.79
n.toFixed(5): -444123.78964
n.toFixed(20): -444123.78963636362459510565
-RangeError: toFixed() argument must be between 0 and 20
-RangeError: toFixed() argument must be between 0 and 20
+RangeError: toFixed() argument must be between 0 and 100
n.toExponential(): -4.441237896363636e+5
n.toExponential(2): -4.44e+5
n.toExponential(5): -4.44124e+5
@@ -98,8 +94,7 @@
n.toFixed(2): 0.00
n.toFixed(5): 0.00000
n.toFixed(20): 0.00000000000000000000
-RangeError: toFixed() argument must be between 0 and 20
-RangeError: toFixed() argument must be between 0 and 20
+RangeError: toFixed() argument must be between 0 and 100
n.toExponential(): 0e+0
n.toExponential(2): 0.00e+0
n.toExponential(5): 0.00000e+0
@@ -120,8 +115,7 @@
n.toFixed(2): 1e+21
n.toFixed(5): 1e+21
n.toFixed(20): 1e+21
-RangeError: toFixed() argument must be between 0 and 20
-RangeError: toFixed() argument must be between 0 and 20
+RangeError: toFixed() argument must be between 0 and 100
n.toExponential(): 1e+21
n.toExponential(2): 1.00e+21
n.toExponential(5): 1.00000e+21
Modified: trunk/JSTests/ChakraCore/test/es5/exceptions3.baseline-jsc (250388 => 250389)
--- trunk/JSTests/ChakraCore/test/es5/exceptions3.baseline-jsc 2019-09-26 18:04:31 UTC (rev 250388)
+++ trunk/JSTests/ChakraCore/test/es5/exceptions3.baseline-jsc 2019-09-26 18:17:52 UTC (rev 250389)
@@ -21,8 +21,8 @@
true.anchor();; -expected: es3, es5 TypeError ::: TypeError: true.anchor is not a function. (In 'true.anchor()', 'true.anchor' is undefined)
new Array(12.4) - RangeError exception: expected in es3 and es5::: RangeError: Array size is not a small enough positive integer.
new Array(12.4); x.length = 12.5; - RangeError exception: es5-expected, ES3-not expected ::: RangeError: Invalid array length
-(123.45).toFixed(25); - RangeError exception : expected es3, es5::: RangeError: toFixed() argument must be between 0 and 20
-(123.45).toExponential(-25); - RangeError exception : expected es3, es5 ::: RangeError: toExponential() argument must be between 0 and 20
+(123.45).toFixed(25); - no exception: not expected es3, es5
+(123.45).toExponential(-25); - RangeError exception : expected es3, es5 ::: RangeError: toExponential() argument must be between 0 and 100
eval("blah."); -expected es3-EvalError exception : expected es5-SyntaxException ::: SyntaxError: Unexpected end of script
f = new Function("a", "b", "return a+b."); -expected es3 and es5-SyntaxError exception ::: SyntaxError: Unexpected token '}'. Expected a property name after '.'.
var num = 0.0009;var x = num.toFixed(3); - no exception: not expected es3, es5 ::: value = 0.001
Modified: trunk/JSTests/ChangeLog (250388 => 250389)
--- trunk/JSTests/ChangeLog 2019-09-26 18:04:31 UTC (rev 250388)
+++ trunk/JSTests/ChangeLog 2019-09-26 18:17:52 UTC (rev 250389)
@@ -1,3 +1,14 @@
+2019-09-26 Alexey Shvayka <[email protected]>
+
+ toExponential, toFixed, and toPrecision should allow arguments up to 100
+ https://bugs.webkit.org/show_bug.cgi?id=199163
+
+ Reviewed by Ross Kirsling.
+
+ * ChakraCore/test/Number/toString_3.baseline-jsc:
+ * ChakraCore/test/es5/exceptions3.baseline-jsc:
+ * test262/expectations.yaml: Mark 6 test cases as passing.
+
2019-09-24 Alexey Shvayka <[email protected]>
[ES6] Come up with a test for Proxy.[[GetOwnProperty]] that tests the isExtensible error when the result of the trap is undefined
Modified: trunk/JSTests/test262/expectations.yaml (250388 => 250389)
--- trunk/JSTests/test262/expectations.yaml 2019-09-26 18:04:31 UTC (rev 250388)
+++ trunk/JSTests/test262/expectations.yaml 2019-09-26 18:17:52 UTC (rev 250389)
@@ -1212,15 +1212,6 @@
test/built-ins/Number/proto-from-ctor-realm.js:
default: 'Test262Error: Expected SameValue(«0», «0») to be true'
strict mode: 'Test262Error: Expected SameValue(«0», «0») to be true'
-test/built-ins/Number/prototype/toExponential/range.js:
- default: 'RangeError: toExponential() argument must be between 0 and 20'
- strict mode: 'RangeError: toExponential() argument must be between 0 and 20'
-test/built-ins/Number/prototype/toFixed/range.js:
- default: 'RangeError: toFixed() argument must be between 0 and 20'
- strict mode: 'RangeError: toFixed() argument must be between 0 and 20'
-test/built-ins/Number/prototype/toPrecision/range.js:
- default: 'RangeError: toPrecision() argument must be between 1 and 21'
- strict mode: 'RangeError: toPrecision() argument must be between 1 and 21'
test/built-ins/Object/defineProperties/15.2.3.7-2-15.js:
default: 'TypeError: Property description must be an object.'
strict mode: 'TypeError: Property description must be an object.'
Modified: trunk/LayoutTests/ChangeLog (250388 => 250389)
--- trunk/LayoutTests/ChangeLog 2019-09-26 18:04:31 UTC (rev 250388)
+++ trunk/LayoutTests/ChangeLog 2019-09-26 18:17:52 UTC (rev 250389)
@@ -1,3 +1,19 @@
+2019-09-26 Alexey Shvayka <[email protected]>
+
+ toExponential, toFixed, and toPrecision should allow arguments up to 100
+ https://bugs.webkit.org/show_bug.cgi?id=199163
+
+ Reviewed by Ross Kirsling.
+
+ * js/dom/number-tofixed-expected.txt:
+ * js/dom/number-toprecision-expected.txt:
+ * js/dom/script-tests/number-tofixed.js:
+ * js/dom/script-tests/number-toprecision.js:
+ * js/kde/Number-expected.txt:
+ * js/kde/script-tests/Number.js:
+ * js/number-toExponential-expected.txt:
+ * js/script-tests/number-toExponential.js:
+
2019-09-26 Russell Epstein <[email protected]>
Layout Test platform/ios/ios/fast/text/opticalFont.html is Failing on iOS13.
Modified: trunk/LayoutTests/js/dom/number-tofixed-expected.txt (250388 => 250389)
--- trunk/LayoutTests/js/dom/number-tofixed-expected.txt 2019-09-26 18:04:31 UTC (rev 250388)
+++ trunk/LayoutTests/js/dom/number-tofixed-expected.txt 2019-09-26 18:17:52 UTC (rev 250389)
@@ -42,16 +42,16 @@
PASS (1234.567).toFixed(2.9) is "1234.57"
PASS (1234.567).toFixed(5) is "1234.56700"
PASS (1234.567).toFixed(20) is "1234.56700000000000727596"
-PASS (1234.567).toFixed(21) threw exception RangeError: toFixed() argument must be between 0 and 20.
-PASS (1234.567).toFixed(100) threw exception RangeError: toFixed() argument must be between 0 and 20.
-PASS (1234.567).toFixed(101) threw exception RangeError: toFixed() argument must be between 0 and 20.
-PASS (1234.567).toFixed(-1) threw exception RangeError: toFixed() argument must be between 0 and 20.
-PASS (1234.567).toFixed(-4) threw exception RangeError: toFixed() argument must be between 0 and 20.
-PASS (1234.567).toFixed(-5) threw exception RangeError: toFixed() argument must be between 0 and 20.
-PASS (1234.567).toFixed(-20) threw exception RangeError: toFixed() argument must be between 0 and 20.
-PASS (1234.567).toFixed(-21) threw exception RangeError: toFixed() argument must be between 0 and 20.
-PASS (1234.567).toFixed(posInf) threw exception RangeError: toFixed() argument must be between 0 and 20.
-PASS (1234.567).toFixed(negInf) threw exception RangeError: toFixed() argument must be between 0 and 20.
+PASS (1234.567).toFixed(21) is "1234.567000000000007275958"
+PASS (1234.567).toFixed(100) is "1234.5670000000000072759576141834259033203125000000000000000000000000000000000000000000000000000000000000"
+PASS (1234.567).toFixed(101) threw exception RangeError: toFixed() argument must be between 0 and 100.
+PASS (1234.567).toFixed(-1) threw exception RangeError: toFixed() argument must be between 0 and 100.
+PASS (1234.567).toFixed(-4) threw exception RangeError: toFixed() argument must be between 0 and 100.
+PASS (1234.567).toFixed(-5) threw exception RangeError: toFixed() argument must be between 0 and 100.
+PASS (1234.567).toFixed(-20) threw exception RangeError: toFixed() argument must be between 0 and 100.
+PASS (1234.567).toFixed(-21) threw exception RangeError: toFixed() argument must be between 0 and 100.
+PASS (1234.567).toFixed(posInf) threw exception RangeError: toFixed() argument must be between 0 and 100.
+PASS (1234.567).toFixed(negInf) threw exception RangeError: toFixed() argument must be between 0 and 100.
PASS posInf.toFixed() is "Infinity"
PASS negInf.toFixed() is "-Infinity"
PASS nan.toFixed() is "NaN"
Modified: trunk/LayoutTests/js/dom/number-toprecision-expected.txt (250388 => 250389)
--- trunk/LayoutTests/js/dom/number-toprecision-expected.txt 2019-09-26 18:04:31 UTC (rev 250388)
+++ trunk/LayoutTests/js/dom/number-toprecision-expected.txt 2019-09-26 18:17:52 UTC (rev 250389)
@@ -11,11 +11,11 @@
PASS (0.0).toPrecision() is "0"
PASS (-0.0).toPrecision() is "0"
PASS (1234.567).toPrecision() is "1234.567"
-PASS (1234.567).toPrecision(0) threw exception RangeError: toPrecision() argument must be between 1 and 21.
-PASS (1234.567).toPrecision(null) threw exception RangeError: toPrecision() argument must be between 1 and 21.
-PASS (1234.567).toPrecision(false) threw exception RangeError: toPrecision() argument must be between 1 and 21.
-PASS (1234.567).toPrecision('foo') threw exception RangeError: toPrecision() argument must be between 1 and 21.
-PASS (1234.567).toPrecision(-1) threw exception RangeError: toPrecision() argument must be between 1 and 21.
+PASS (1234.567).toPrecision(0) threw exception RangeError: toPrecision() argument must be between 1 and 100.
+PASS (1234.567).toPrecision(null) threw exception RangeError: toPrecision() argument must be between 1 and 100.
+PASS (1234.567).toPrecision(false) threw exception RangeError: toPrecision() argument must be between 1 and 100.
+PASS (1234.567).toPrecision('foo') threw exception RangeError: toPrecision() argument must be between 1 and 100.
+PASS (1234.567).toPrecision(-1) threw exception RangeError: toPrecision() argument must be between 1 and 100.
PASS (1234.567).toPrecision(1) is "1e+3"
PASS (1234.567).toPrecision(true) is "1e+3"
PASS (1234.567).toPrecision('1') is "1e+3"
@@ -23,12 +23,12 @@
PASS (1234.567).toPrecision(2.9) is "1.2e+3"
PASS (1234.567).toPrecision(5) is "1234.6"
PASS (1234.567).toPrecision(21) is "1234.56700000000000728"
-PASS (1234.567).toPrecision(22) threw exception RangeError: toPrecision() argument must be between 1 and 21.
-PASS (1234.567).toPrecision(100) threw exception RangeError: toPrecision() argument must be between 1 and 21.
-PASS (1234.567).toPrecision(101) threw exception RangeError: toPrecision() argument must be between 1 and 21.
-PASS (1234.567).toPrecision(posInf) threw exception RangeError: toPrecision() argument must be between 1 and 21.
-PASS (1234.567).toPrecision(negInf) threw exception RangeError: toPrecision() argument must be between 1 and 21.
-PASS (1234.567).toPrecision(nan) threw exception RangeError: toPrecision() argument must be between 1 and 21.
+PASS (1234.567).toPrecision(22) is "1234.567000000000007276"
+PASS (1234.567).toPrecision(100) is "1234.567000000000007275957614183425903320312500000000000000000000000000000000000000000000000000000000"
+PASS (1234.567).toPrecision(101) threw exception RangeError: toPrecision() argument must be between 1 and 100.
+PASS (1234.567).toPrecision(posInf) threw exception RangeError: toPrecision() argument must be between 1 and 100.
+PASS (1234.567).toPrecision(negInf) threw exception RangeError: toPrecision() argument must be between 1 and 100.
+PASS (1234.567).toPrecision(nan) threw exception RangeError: toPrecision() argument must be between 1 and 100.
PASS posInf.toPrecision() is "Infinity"
PASS negInf.toPrecision() is "-Infinity"
PASS nan.toPrecision() is "NaN"
Modified: trunk/LayoutTests/js/dom/script-tests/number-tofixed.js (250388 => 250389)
--- trunk/LayoutTests/js/dom/script-tests/number-tofixed.js 2019-09-26 18:04:31 UTC (rev 250388)
+++ trunk/LayoutTests/js/dom/script-tests/number-tofixed.js 2019-09-26 18:17:52 UTC (rev 250389)
@@ -60,10 +60,9 @@
shouldBeEqualToString("(1234.567).toFixed(2.9)", "1234.57");
shouldBeEqualToString("(1234.567).toFixed(5)", "1234.56700");
shouldBeEqualToString("(1234.567).toFixed(20)", "1234.56700000000000727596");
+shouldBeEqualToString("(1234.567).toFixed(21)", "1234.567000000000007275958");
+shouldBeEqualToString("(1234.567).toFixed(100)", "1234.5670000000000072759576141834259033203125000000000000000000000000000000000000000000000000000000000000");
-// SpiderMonkey allows precision values -20 to 100, the spec only allows 0 to 20
-shouldThrow("(1234.567).toFixed(21)");
-shouldThrow("(1234.567).toFixed(100)");
shouldThrow("(1234.567).toFixed(101)");
shouldThrow("(1234.567).toFixed(-1)");
shouldThrow("(1234.567).toFixed(-4)");
Modified: trunk/LayoutTests/js/dom/script-tests/number-toprecision.js (250388 => 250389)
--- trunk/LayoutTests/js/dom/script-tests/number-toprecision.js 2019-09-26 18:04:31 UTC (rev 250388)
+++ trunk/LayoutTests/js/dom/script-tests/number-toprecision.js 2019-09-26 18:17:52 UTC (rev 250389)
@@ -28,11 +28,9 @@
shouldBeEqualToString("(1234.567).toPrecision(2.9)", "1.2e+3");
shouldBeEqualToString("(1234.567).toPrecision(5)", "1234.6");
shouldBeEqualToString("(1234.567).toPrecision(21)", "1234.56700000000000728");
-// SpiderMonkey allows precision values 1 to 100, we implement the spec and only allow 1 to 21.
-shouldThrow("(1234.567).toPrecision(22)");
-shouldThrow("(1234.567).toPrecision(100)");
+shouldBeEqualToString("(1234.567).toPrecision(22)", "1234.567000000000007276");
+shouldBeEqualToString("(1234.567).toPrecision(100)", "1234.567000000000007275957614183425903320312500000000000000000000000000000000000000000000000000000000");
shouldThrow("(1234.567).toPrecision(101)");
-
shouldThrow("(1234.567).toPrecision(posInf)");
shouldThrow("(1234.567).toPrecision(negInf)");
shouldThrow("(1234.567).toPrecision(nan)"); // nan is treated like 0
Modified: trunk/LayoutTests/js/kde/Number-expected.txt (250388 => 250389)
--- trunk/LayoutTests/js/kde/Number-expected.txt 2019-09-26 18:04:31 UTC (rev 250388)
+++ trunk/LayoutTests/js/kde/Number-expected.txt 2019-09-26 18:17:52 UTC (rev 250389)
@@ -63,11 +63,11 @@
PASS toFixedOrException(2,-1).indexOf('Range') >= 0 is true
PASS Number(2).toFixed(0) is "2"
PASS Number(2).toFixed(20) is "2.00000000000000000000"
-PASS toFixedOrException(2,21).indexOf('Range') >= 0 is true
+PASS toFixedOrException(2,101).indexOf('Range') >= 0 is true
PASS toFixedOrException(-2,-1).indexOf('Range') >= 0 is true
PASS Number(-2).toFixed(0) is "-2"
PASS Number(-2).toFixed(20) is "-2.00000000000000000000"
-PASS toFixedOrException(-2,21).indexOf('Range') >= 0 is true
+PASS toFixedOrException(-2,101).indexOf('Range') >= 0 is true
PASS Number(NaN).toExponential() is "NaN"
PASS Number(Infinity).toExponential() is "Infinity"
PASS Number(-Infinity).toExponential() is "-Infinity"
@@ -97,7 +97,7 @@
PASS Number(123.456).toExponential(18) is "1.234560000000000031e+2"
PASS Number(123.456).toExponential(19) is "1.2345600000000000307e+2"
PASS Number(123.456).toExponential(20) is "1.23456000000000003070e+2"
-PASS try { Number(123.456).toExponential(21) } catch (e) { String(e).indexOf('Range') >= 0; } is true
+PASS try { Number(123.456).toExponential(101) } catch (e) { String(e).indexOf('Range') >= 0; } is true
PASS Number(-123.456).toExponential() is "-1.23456e+2"
PASS try { Number(-123.456).toExponential(-1) } catch (e) { String(e).indexOf('Range') >= 0; } is true
PASS Number(-123.456).toExponential(0) is "-1e+2"
@@ -121,7 +121,7 @@
PASS Number(-123.456).toExponential(18) is "-1.234560000000000031e+2"
PASS Number(-123.456).toExponential(19) is "-1.2345600000000000307e+2"
PASS Number(-123.456).toExponential(20) is "-1.23456000000000003070e+2"
-PASS try { Number(-123.456).toExponential(21) } catch (e) { String(e).indexOf('Range') >= 0; } is true
+PASS try { Number(-123.456).toExponential(101) } catch (e) { String(e).indexOf('Range') >= 0; } is true
PASS Number(.000123456).toExponential() is "1.23456e-4"
PASS try { Number(.000123456).toExponential(-1) } catch (e) { String(e).indexOf('Range') >= 0; } is true
PASS Number(.000123456).toExponential(0) is "1e-4"
@@ -145,7 +145,7 @@
PASS Number(.000123456).toExponential(18) is "1.234560000000000052e-4"
PASS Number(.000123456).toExponential(19) is "1.2345600000000000519e-4"
PASS Number(.000123456).toExponential(20) is "1.23456000000000005188e-4"
-PASS try { Number(.000123456).toExponential(21) } catch (e) { String(e).indexOf('Range') >= 0; } is true
+PASS try { Number(.000123456).toExponential(101) } catch (e) { String(e).indexOf('Range') >= 0; } is true
PASS Number(-.000123456).toExponential() is "-1.23456e-4"
PASS try { Number(-.000123456).toExponential(-1) } catch (e) { String(e).indexOf('Range') >= 0; } is true
PASS Number(-.000123456).toExponential(0) is "-1e-4"
@@ -169,7 +169,7 @@
PASS Number(-.000123456).toExponential(18) is "-1.234560000000000052e-4"
PASS Number(-.000123456).toExponential(19) is "-1.2345600000000000519e-4"
PASS Number(-.000123456).toExponential(20) is "-1.23456000000000005188e-4"
-PASS try { Number(-.000123456).toExponential(21) } catch (e) { String(e).indexOf('Range') >= 0; } is true
+PASS try { Number(-.000123456).toExponential(101) } catch (e) { String(e).indexOf('Range') >= 0; } is true
PASS Number(123.4567890123456789012).toExponential() is "1.2345678901234568e+2"
PASS try { Number(123.4567890123456789012).toExponential(-1) } catch (e) { String(e).indexOf('Range') >= 0; } is true
PASS Number(123.4567890123456789012).toExponential(0) is "1e+2"
@@ -193,7 +193,7 @@
PASS Number(123.4567890123456789012).toExponential(18) is "1.234567890123456806e+2"
PASS Number(123.4567890123456789012).toExponential(19) is "1.2345678901234568059e+2"
PASS Number(123.4567890123456789012).toExponential(20) is "1.23456789012345680590e+2"
-PASS try { Number(123.4567890123456789012).toExponential(21) } catch (e) { String(e).indexOf('Range') >= 0; } is true
+PASS try { Number(123.4567890123456789012).toExponential(101) } catch (e) { String(e).indexOf('Range') >= 0; } is true
PASS Number(-123.4567890123456789012).toExponential() is "-1.2345678901234568e+2"
PASS try { Number(-123.4567890123456789012).toExponential(-1) } catch (e) { String(e).indexOf('Range') >= 0; } is true
PASS Number(-123.4567890123456789012).toExponential(0) is "-1e+2"
@@ -217,7 +217,7 @@
PASS Number(-123.4567890123456789012).toExponential(18) is "-1.234567890123456806e+2"
PASS Number(-123.4567890123456789012).toExponential(19) is "-1.2345678901234568059e+2"
PASS Number(-123.4567890123456789012).toExponential(20) is "-1.23456789012345680590e+2"
-PASS try { Number(-123.4567890123456789012).toExponential(21) } catch (e) { String(e).indexOf('Range') >= 0; } is true
+PASS try { Number(-123.4567890123456789012).toExponential(101) } catch (e) { String(e).indexOf('Range') >= 0; } is true
PASS Number(.0000000000000000000001).toExponential() is "1e-22"
PASS Number(.0000000000000000000012).toExponential() is "1.2e-21"
PASS Number(.0000000000000000000123).toExponential() is "1.23e-20"
@@ -307,8 +307,8 @@
PASS try { Number(1).toPrecision(-1); } catch (e) { String(e).indexOf('Range') >= 0; } is true
PASS try { Number(1).toPrecision(0); } catch (e) { String(e).indexOf('Range') >= 0; } is true
PASS try { Number(1).toPrecision(1); } catch (e) { String(e); } is "1"
-PASS try { Number(1).toPrecision(21); } catch (e) { String(e); } is "1.00000000000000000000"
-PASS try { Number(1).toPrecision(22); } catch (e) { String(e).indexOf('Range') >= 0; } is true
+PASS try { Number(1).toPrecision(100); } catch (e) { String(e); } is "1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
+PASS try { Number(1).toPrecision(101); } catch (e) { String(e).indexOf('Range') >= 0; } is true
PASS Number(NaN).toPrecision() is "NaN"
PASS Number(NaN).toPrecision(1) is "NaN"
PASS Number(Infinity).toPrecision() is "Infinity"
Modified: trunk/LayoutTests/js/kde/script-tests/Number.js (250388 => 250389)
--- trunk/LayoutTests/js/kde/script-tests/Number.js 2019-09-26 18:04:31 UTC (rev 250388)
+++ trunk/LayoutTests/js/kde/script-tests/Number.js 2019-09-26 18:17:52 UTC (rev 250389)
@@ -74,11 +74,11 @@
shouldBeTrue("toFixedOrException(2,-1).indexOf('Range') >= 0");
shouldBe("Number(2).toFixed(0)","\"2\"");
shouldBe("Number(2).toFixed(20)","\"2.00000000000000000000\"");
-shouldBeTrue("toFixedOrException(2,21).indexOf('Range') >= 0");
+shouldBeTrue("toFixedOrException(2,101).indexOf('Range') >= 0");
shouldBeTrue("toFixedOrException(-2,-1).indexOf('Range') >= 0");
shouldBe("Number(-2).toFixed(0)","\"-2\"");
shouldBe("Number(-2).toFixed(20)","\"-2.00000000000000000000\"");
-shouldBeTrue("toFixedOrException(-2,21).indexOf('Range') >= 0");
+shouldBeTrue("toFixedOrException(-2,101).indexOf('Range') >= 0");
@@ -112,7 +112,7 @@
shouldBe("Number(123.456).toExponential(18)","\"1.234560000000000031e+2\"");
shouldBe("Number(123.456).toExponential(19)","\"1.2345600000000000307e+2\"");
shouldBe("Number(123.456).toExponential(20)","\"1.23456000000000003070e+2\"");
-shouldBeTrue("try { Number(123.456).toExponential(21) } catch (e) { String(e).indexOf('Range') >= 0; }");
+shouldBeTrue("try { Number(123.456).toExponential(101) } catch (e) { String(e).indexOf('Range') >= 0; }");
shouldBe("Number(-123.456).toExponential()","\"-1.23456e+2\"");
shouldBeTrue("try { Number(-123.456).toExponential(-1) } catch (e) { String(e).indexOf('Range') >= 0; }");
shouldBe("Number(-123.456).toExponential(0)","\"-1e+2\"");
@@ -136,7 +136,7 @@
shouldBe("Number(-123.456).toExponential(18)","\"-1.234560000000000031e+2\"");
shouldBe("Number(-123.456).toExponential(19)","\"-1.2345600000000000307e+2\"");
shouldBe("Number(-123.456).toExponential(20)","\"-1.23456000000000003070e+2\"");
-shouldBeTrue("try { Number(-123.456).toExponential(21) } catch (e) { String(e).indexOf('Range') >= 0; }");
+shouldBeTrue("try { Number(-123.456).toExponential(101) } catch (e) { String(e).indexOf('Range') >= 0; }");
shouldBe("Number(.000123456).toExponential()","\"1.23456e-4\"");
shouldBeTrue("try { Number(.000123456).toExponential(-1) } catch (e) { String(e).indexOf('Range') >= 0; }");
shouldBe("Number(.000123456).toExponential(0)","\"1e-4\"");
@@ -160,7 +160,7 @@
shouldBe("Number(.000123456).toExponential(18)","\"1.234560000000000052e-4\"");
shouldBe("Number(.000123456).toExponential(19)","\"1.2345600000000000519e-4\"");
shouldBe("Number(.000123456).toExponential(20)","\"1.23456000000000005188e-4\"");
-shouldBeTrue("try { Number(.000123456).toExponential(21) } catch (e) { String(e).indexOf('Range') >= 0; }");
+shouldBeTrue("try { Number(.000123456).toExponential(101) } catch (e) { String(e).indexOf('Range') >= 0; }");
shouldBe("Number(-.000123456).toExponential()","\"-1.23456e-4\"");
shouldBeTrue("try { Number(-.000123456).toExponential(-1) } catch (e) { String(e).indexOf('Range') >= 0; }");
shouldBe("Number(-.000123456).toExponential(0)","\"-1e-4\"");
@@ -184,7 +184,7 @@
shouldBe("Number(-.000123456).toExponential(18)","\"-1.234560000000000052e-4\"");
shouldBe("Number(-.000123456).toExponential(19)","\"-1.2345600000000000519e-4\"");
shouldBe("Number(-.000123456).toExponential(20)","\"-1.23456000000000005188e-4\"");
-shouldBeTrue("try { Number(-.000123456).toExponential(21) } catch (e) { String(e).indexOf('Range') >= 0; }");
+shouldBeTrue("try { Number(-.000123456).toExponential(101) } catch (e) { String(e).indexOf('Range') >= 0; }");
shouldBe("Number(123.4567890123456789012).toExponential()","\"1.2345678901234568e+2\"");
shouldBeTrue("try { Number(123.4567890123456789012).toExponential(-1) } catch (e) { String(e).indexOf('Range') >= 0; }");
shouldBe("Number(123.4567890123456789012).toExponential(0)","\"1e+2\"");
@@ -208,7 +208,7 @@
shouldBe("Number(123.4567890123456789012).toExponential(18)","\"1.234567890123456806e+2\"");
shouldBe("Number(123.4567890123456789012).toExponential(19)","\"1.2345678901234568059e+2\"");
shouldBe("Number(123.4567890123456789012).toExponential(20)","\"1.23456789012345680590e+2\"");
-shouldBeTrue("try { Number(123.4567890123456789012).toExponential(21) } catch (e) { String(e).indexOf('Range') >= 0; }");
+shouldBeTrue("try { Number(123.4567890123456789012).toExponential(101) } catch (e) { String(e).indexOf('Range') >= 0; }");
shouldBe("Number(-123.4567890123456789012).toExponential()","\"-1.2345678901234568e+2\"");
shouldBeTrue("try { Number(-123.4567890123456789012).toExponential(-1) } catch (e) { String(e).indexOf('Range') >= 0; }");
shouldBe("Number(-123.4567890123456789012).toExponential(0)","\"-1e+2\"");
@@ -232,7 +232,7 @@
shouldBe("Number(-123.4567890123456789012).toExponential(18)","\"-1.234567890123456806e+2\"");
shouldBe("Number(-123.4567890123456789012).toExponential(19)","\"-1.2345678901234568059e+2\"");
shouldBe("Number(-123.4567890123456789012).toExponential(20)","\"-1.23456789012345680590e+2\"");
-shouldBeTrue("try { Number(-123.4567890123456789012).toExponential(21) } catch (e) { String(e).indexOf('Range') >= 0; }");
+shouldBeTrue("try { Number(-123.4567890123456789012).toExponential(101) } catch (e) { String(e).indexOf('Range') >= 0; }");
shouldBe("Number(.0000000000000000000001).toExponential()","\"1e-22\"");
shouldBe("Number(.0000000000000000000012).toExponential()","\"1.2e-21\"");
shouldBe("Number(.0000000000000000000123).toExponential()","\"1.23e-20\"");
@@ -323,8 +323,8 @@
shouldBeTrue("try { Number(1).toPrecision(-1); } catch (e) { String(e).indexOf('Range') >= 0; }");
shouldBeTrue("try { Number(1).toPrecision(0); } catch (e) { String(e).indexOf('Range') >= 0; }");
shouldBe("try { Number(1).toPrecision(1); } catch (e) { String(e); }","\"1\"");
-shouldBe("try { Number(1).toPrecision(21); } catch (e) { String(e); }","\"1.00000000000000000000\"");
-shouldBeTrue("try { Number(1).toPrecision(22); } catch (e) { String(e).indexOf('Range') >= 0; }");
+shouldBe("try { Number(1).toPrecision(100); } catch (e) { String(e); }","\"1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\"");
+shouldBeTrue("try { Number(1).toPrecision(101); } catch (e) { String(e).indexOf('Range') >= 0; }");
shouldBe("Number(NaN).toPrecision()","\"NaN\"");
shouldBe("Number(NaN).toPrecision(1)","\"NaN\"");
shouldBe("Number(Infinity).toPrecision()","\"Infinity\"");
Modified: trunk/LayoutTests/js/number-toExponential-expected.txt (250388 => 250389)
--- trunk/LayoutTests/js/number-toExponential-expected.txt 2019-09-26 18:04:31 UTC (rev 250388)
+++ trunk/LayoutTests/js/number-toExponential-expected.txt 2019-09-26 18:17:52 UTC (rev 250389)
@@ -17,12 +17,12 @@
PASS (123.456).toExponential(5) is "1.23456e+2"
PASS (123.456).toExponential(6) is "1.234560e+2"
PASS (123.456).toExponential(20) is "1.23456000000000003070e+2"
-PASS (123.456).toExponential(21) threw exception RangeError: toExponential() argument must be between 0 and 20.
-PASS (123.456).toExponential(100) threw exception RangeError: toExponential() argument must be between 0 and 20.
-PASS (123.456).toExponential(101) threw exception RangeError: toExponential() argument must be between 0 and 20.
-PASS (123.456).toExponential(-1) threw exception RangeError: toExponential() argument must be between 0 and 20.
-PASS (1234.567).toExponential(posInf) threw exception RangeError: toExponential() argument must be between 0 and 20.
-PASS (1234.567).toExponential(negInf) threw exception RangeError: toExponential() argument must be between 0 and 20.
+PASS (123.456).toExponential(21) is "1.234560000000000030695e+2"
+PASS (123.456).toExponential(100) is "1.2345600000000000306954461848363280296325683593750000000000000000000000000000000000000000000000000000e+2"
+PASS (123.456).toExponential(101) threw exception RangeError: toExponential() argument must be between 0 and 100.
+PASS (123.456).toExponential(-1) threw exception RangeError: toExponential() argument must be between 0 and 100.
+PASS (1234.567).toExponential(posInf) threw exception RangeError: toExponential() argument must be between 0 and 100.
+PASS (1234.567).toExponential(negInf) threw exception RangeError: toExponential() argument must be between 0 and 100.
PASS posInf.toExponential() is "Infinity"
PASS negInf.toExponential() is "-Infinity"
PASS nan.toExponential() is "NaN"
Modified: trunk/LayoutTests/js/script-tests/number-toExponential.js (250388 => 250389)
--- trunk/LayoutTests/js/script-tests/number-toExponential.js 2019-09-26 18:04:31 UTC (rev 250388)
+++ trunk/LayoutTests/js/script-tests/number-toExponential.js 2019-09-26 18:17:52 UTC (rev 250389)
@@ -27,10 +27,9 @@
shouldBeEqualToString("(123.456).toExponential(5)", "1.23456e+2");
shouldBeEqualToString("(123.456).toExponential(6)", "1.234560e+2");
shouldBeEqualToString("(123.456).toExponential(20)", "1.23456000000000003070e+2");
+shouldBeEqualToString("(123.456).toExponential(21)", "1.234560000000000030695e+2");
+shouldBeEqualToString("(123.456).toExponential(100)", "1.2345600000000000306954461848363280296325683593750000000000000000000000000000000000000000000000000000e+2");
-// SpiderMonkey allows precision values 0 to 100, we only allow 0 to 20 currently
-shouldThrow("(123.456).toExponential(21)");
-shouldThrow("(123.456).toExponential(100)");
shouldThrow("(123.456).toExponential(101)");
shouldThrow("(123.456).toExponential(-1)");
Modified: trunk/Source/_javascript_Core/ChangeLog (250388 => 250389)
--- trunk/Source/_javascript_Core/ChangeLog 2019-09-26 18:04:31 UTC (rev 250388)
+++ trunk/Source/_javascript_Core/ChangeLog 2019-09-26 18:17:52 UTC (rev 250389)
@@ -1,3 +1,21 @@
+2019-09-26 Alexey Shvayka <[email protected]>
+
+ toExponential, toFixed, and toPrecision should allow arguments up to 100
+ https://bugs.webkit.org/show_bug.cgi?id=199163
+
+ Reviewed by Ross Kirsling.
+
+ Previously, the spec gave fixed range of [0,20] for Number.prototype.{toExponential,toFixed} argument and
+ range of [1,21] for Number.prototype.toPrecision argument, but allowed implementations to permit a larger range.
+ Historically, only SpiderMonkey accepted a larger range, and other implementations threw a RangeError outside the range.
+ Later the spec was changed (see https://github.com/tc39/ecma262/pull/857) to specify the SpiderMonkey behavior.
+
+ * runtime/NumberPrototype.cpp:
+ (JSC::numberProtoFuncToExponential): Accept arguments between 0 and 100.
+ (JSC::numberProtoFuncToFixed): Accept arguments between 0 and 100.
+ (JSC::numberProtoFuncToPrecision): Accept arguments between 1 and 100.
+ (JSC::getIntegerArgumentInRange): Inline to improve readability.
+
2019-09-26 Mark Lam <[email protected]>
We need to initialize the Gigacage first in setJITEnabled() when disabling the JIT.
Modified: trunk/Source/_javascript_Core/runtime/NumberPrototype.cpp (250388 => 250389)
--- trunk/Source/_javascript_Core/runtime/NumberPrototype.cpp 2019-09-26 18:04:31 UTC (rev 250388)
+++ trunk/Source/_javascript_Core/runtime/NumberPrototype.cpp 2019-09-26 18:17:52 UTC (rev 250389)
@@ -113,25 +113,6 @@
return throwVMTypeError(exec, scope, WTF::makeString("thisNumberValue called on incompatible ", typeString));
}
-static ALWAYS_INLINE bool getIntegerArgumentInRange(ExecState* exec, int low, int high, int& result, bool& isUndefined)
-{
- result = 0;
- isUndefined = false;
-
- JSValue argument0 = exec->argument(0);
- if (argument0.isUndefined()) {
- isUndefined = true;
- return true;
- }
-
- double asDouble = argument0.toInteger(exec);
- if (asDouble < low || asDouble > high)
- return false;
-
- result = static_cast<int>(asDouble);
- return true;
-}
-
// The largest finite floating point number is 1.mantissa * 2^(0x7fe-0x3ff).
// Since 2^N in binary is a one bit followed by N zero bits. 1 * 2^3ff requires
// at most 1024 characters to the left of a decimal point, in base 2 (1025 if
@@ -414,10 +395,9 @@
if (!toThisNumber(vm, exec->thisValue(), x))
return throwVMToThisNumberError(exec, scope, exec->thisValue());
+ JSValue arg = exec->argument(0);
// Perform ToInteger on the argument before remaining steps.
- int decimalPlacesInExponent;
- bool isUndefined;
- bool inRange = getIntegerArgumentInRange(exec, 0, 20, decimalPlacesInExponent, isUndefined);
+ int decimalPlaces = static_cast<int>(arg.toInteger(exec));
RETURN_IF_EXCEPTION(scope, { });
// Handle NaN and Infinity.
@@ -424,8 +404,8 @@
if (!std::isfinite(x))
return JSValue::encode(jsNontrivialString(vm, String::number(x)));
- if (!inRange)
- return throwVMError(exec, scope, createRangeError(exec, "toExponential() argument must be between 0 and 20"_s));
+ if (decimalPlaces < 0 || decimalPlaces > 100)
+ return throwVMRangeError(exec, scope, "toExponential() argument must be between 0 and 100"_s);
// Round if the argument is not undefined, always format as exponential.
NumberToStringBuffer buffer;
@@ -432,9 +412,10 @@
DoubleConversionStringBuilder builder { &buffer[0], sizeof(buffer) };
const DoubleToStringConverter& converter = DoubleToStringConverter::EcmaScriptConverter();
builder.Reset();
- isUndefined
- ? converter.ToExponential(x, -1, &builder)
- : converter.ToExponential(x, decimalPlacesInExponent, &builder);
+ if (arg.isUndefined())
+ converter.ToExponential(x, -1, &builder);
+ else
+ converter.ToExponential(x, decimalPlaces, &builder);
return JSValue::encode(jsString(vm, builder.Finalize()));
}
@@ -451,13 +432,10 @@
if (!toThisNumber(vm, exec->thisValue(), x))
return throwVMToThisNumberError(exec, scope, exec->thisValue());
- // Get the argument.
- int decimalPlaces;
- bool isUndefined; // This is ignored; undefined treated as 0.
- bool inRange = getIntegerArgumentInRange(exec, 0, 20, decimalPlaces, isUndefined);
+ int decimalPlaces = static_cast<int>(exec->argument(0).toInteger(exec));
RETURN_IF_EXCEPTION(scope, { });
- if (!inRange)
- return throwVMError(exec, scope, createRangeError(exec, "toFixed() argument must be between 0 and 20"_s));
+ if (decimalPlaces < 0 || decimalPlaces > 100)
+ return throwVMRangeError(exec, scope, "toFixed() argument must be between 0 and 100"_s);
// 15.7.4.5.7 states "If x >= 10^21, then let m = ToString(x)"
// This also covers Ininity, and structure the check so that NaN
@@ -488,22 +466,21 @@
if (!toThisNumber(vm, exec->thisValue(), x))
return throwVMToThisNumberError(exec, scope, exec->thisValue());
+ JSValue arg = exec->argument(0);
+ // To precision called with no argument is treated as ToString.
+ if (arg.isUndefined())
+ return JSValue::encode(jsString(vm, String::number(x)));
+
// Perform ToInteger on the argument before remaining steps.
- int significantFigures;
- bool isUndefined;
- bool inRange = getIntegerArgumentInRange(exec, 1, 21, significantFigures, isUndefined);
+ int significantFigures = static_cast<int>(arg.toInteger(exec));
RETURN_IF_EXCEPTION(scope, { });
- // To precision called with no argument is treated as ToString.
- if (isUndefined)
- return JSValue::encode(jsString(vm, String::number(x)));
-
// Handle NaN and Infinity.
if (!std::isfinite(x))
return JSValue::encode(jsNontrivialString(vm, String::number(x)));
- if (!inRange)
- return throwVMError(exec, scope, createRangeError(exec, "toPrecision() argument must be between 1 and 21"_s));
+ if (significantFigures < 1 || significantFigures > 100)
+ return throwVMRangeError(exec, scope, "toPrecision() argument must be between 1 and 100"_s);
return JSValue::encode(jsString(vm, String::numberToStringFixedPrecision(x, significantFigures, KeepTrailingZeros)));
}
Modified: trunk/Source/WTF/ChangeLog (250388 => 250389)
--- trunk/Source/WTF/ChangeLog 2019-09-26 18:04:31 UTC (rev 250388)
+++ trunk/Source/WTF/ChangeLog 2019-09-26 18:17:52 UTC (rev 250389)
@@ -1,3 +1,18 @@
+2019-09-26 Alexey Shvayka <[email protected]>
+
+ toExponential, toFixed, and toPrecision should allow arguments up to 100
+ https://bugs.webkit.org/show_bug.cgi?id=199163
+
+ Reviewed by Ross Kirsling.
+
+ Increase size of NumberToStringBuffer: <21 digits> + decimal point + <100 digits> + null char = 123.
+ Increase kMaxFixedDigitsAfterPoint to make Number.prototype.toFixed work with arguments up to 100.
+ Also update other constants to their correct values.
+
+ * wtf/dtoa.h:
+ * wtf/dtoa/double-conversion.cc:
+ * wtf/dtoa/double-conversion.h:
+
2019-09-25 Keith Rollin <[email protected]>
Address static analysis warning in UTextProviderLatin1.cpp: Array access results in a null pointer dereference
Modified: trunk/Source/WTF/wtf/dtoa/double-conversion.cc (250388 => 250389)
--- trunk/Source/WTF/wtf/dtoa/double-conversion.cc 2019-09-26 18:04:31 UTC (rev 250388)
+++ trunk/Source/WTF/wtf/dtoa/double-conversion.cc 2019-09-26 18:17:52 UTC (rev 250389)
@@ -205,8 +205,8 @@
bool DoubleToStringConverter::ToFixed(double value,
int requested_digits,
StringBuilder* result_builder) const {
- ASSERT(kMaxFixedDigitsBeforePoint == 60);
- const double kFirstNonFixed = 1e60;
+ ASSERT(kMaxFixedDigitsBeforePoint == 21);
+ const double kFirstNonFixed = 1e21;
if (Double(value).IsSpecial()) {
return HandleSpecialValues(value, result_builder);
Modified: trunk/Source/WTF/wtf/dtoa/double-conversion.h (250388 => 250389)
--- trunk/Source/WTF/wtf/dtoa/double-conversion.h 2019-09-26 18:04:31 UTC (rev 250388)
+++ trunk/Source/WTF/wtf/dtoa/double-conversion.h 2019-09-26 18:17:52 UTC (rev 250389)
@@ -38,18 +38,18 @@
// When calling ToFixed with a double > 10^kMaxFixedDigitsBeforePoint
// or a requested_digits parameter > kMaxFixedDigitsAfterPoint then the
// function returns false.
- static const int kMaxFixedDigitsBeforePoint = 60;
- static const int kMaxFixedDigitsAfterPoint = 60;
+ static const int kMaxFixedDigitsBeforePoint = 21;
+ static const int kMaxFixedDigitsAfterPoint = 100;
// When calling ToExponential with a requested_digits
// parameter > kMaxExponentialDigits then the function returns false.
- static const int kMaxExponentialDigits = 120;
+ static const int kMaxExponentialDigits = 100;
// When calling ToPrecision with a requested_digits
// parameter < kMinPrecisionDigits or requested_digits > kMaxPrecisionDigits
// then the function returns false.
static const int kMinPrecisionDigits = 1;
- static const int kMaxPrecisionDigits = 120;
+ static const int kMaxPrecisionDigits = 100;
enum Flags {
NO_FLAGS = 0,
Modified: trunk/Source/WTF/wtf/dtoa.h (250388 => 250389)
--- trunk/Source/WTF/wtf/dtoa.h 2019-09-26 18:04:31 UTC (rev 250388)
+++ trunk/Source/WTF/wtf/dtoa.h 2019-09-26 18:17:52 UTC (rev 250389)
@@ -27,7 +27,7 @@
namespace WTF {
-using NumberToStringBuffer = std::array<char, 96>;
+using NumberToStringBuffer = std::array<char, 123>;
WTF_EXPORT_PRIVATE const char* numberToString(float, NumberToStringBuffer&);
WTF_EXPORT_PRIVATE const char* numberToFixedPrecisionString(float, unsigned significantFigures, NumberToStringBuffer&, bool truncateTrailingZeros = false);
Modified: trunk/Tools/ChangeLog (250388 => 250389)
--- trunk/Tools/ChangeLog 2019-09-26 18:04:31 UTC (rev 250388)
+++ trunk/Tools/ChangeLog 2019-09-26 18:17:52 UTC (rev 250389)
@@ -1,3 +1,14 @@
+2019-09-26 Alexey Shvayka <[email protected]>
+
+ toExponential, toFixed, and toPrecision should allow arguments up to 100
+ https://bugs.webkit.org/show_bug.cgi?id=199163
+
+ Reviewed by Ross Kirsling.
+
+ Adjust StringNumberFixedWidth test due to lowering kMaxFixedDigitsBeforePoint.
+
+ * TestWebKitAPI/Tests/WTF/WTFString.cpp:
+
2019-09-26 Jiewen Tan <[email protected]>
TestWebKitAPI.SOAuthorizationSubFrame.AuthorizationOptions is failing consistently on iOS API tests EWS
Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp (250388 => 250389)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp 2019-09-26 18:04:31 UTC (rev 250388)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp 2019-09-26 18:17:52 UTC (rev 250389)
@@ -159,14 +159,12 @@
EXPECT_STREQ("1000.000000", testStringNumberFixedWidth(1e3));
EXPECT_STREQ("10000000000.000000", testStringNumberFixedWidth(1e10));
EXPECT_STREQ("100000000000000000000.000000", testStringNumberFixedWidth(1e20));
- EXPECT_STREQ("1000000000000000000000.000000", testStringNumberFixedWidth(1e21));
- EXPECT_STREQ("1000000000000000019884624838656.000000", testStringNumberFixedWidth(1e30));
+ EXPECT_STREQ("", testStringNumberFixedWidth(1e21));
EXPECT_STREQ("1100.000000", testStringNumberFixedWidth(1.1e3));
EXPECT_STREQ("11000000000.000000", testStringNumberFixedWidth(1.1e10));
EXPECT_STREQ("110000000000000000000.000000", testStringNumberFixedWidth(1.1e20));
- EXPECT_STREQ("1100000000000000000000.000000", testStringNumberFixedWidth(1.1e21));
- EXPECT_STREQ("1099999999999999993725589651456.000000", testStringNumberFixedWidth(1.1e30));
+ EXPECT_STREQ("", testStringNumberFixedWidth(1.1e21));
}
static inline const char* testStringNumber(double number)