WebKit Bugzilla
Attachment 372768 Details for
Bug 199163
: toExponential, toFixed, and toPrecision should allow arguments up to 100
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-199163-20190624195234.patch (text/plain), 40.18 KB, created by
Alexey Shvayka
on 2019-06-24 09:52:36 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Alexey Shvayka
Created:
2019-06-24 09:52:36 PDT
Size:
40.18 KB
patch
obsolete
>Index: JSTests/ChangeLog >=================================================================== >--- JSTests/ChangeLog (revision 246738) >+++ JSTests/ChangeLog (working copy) >@@ -1,3 +1,15 @@ >+2019-06-24 Alexey Shvayka <shvaikalesh@gmail.com> >+ >+ toExponential, toFixed, and toPrecision should allow arguments up to 100 >+ https://bugs.webkit.org/show_bug.cgi?id=199163 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * ChakraCore/test/Number/toString.js: >+ * ChakraCore/test/Number/toString_3.baseline-jsc: >+ * ChakraCore/test/es5/exceptions3.baseline-jsc: >+ * test262/expectations.yaml: Mark 6 test cases as passing. >+ > 2019-06-22 Robin Morisset <rmorisset@apple.com> and Yusuke Suzuki <ysuzuki@apple.com> > > All prototypes should call didBecomePrototype() >Index: JSTests/ChakraCore/test/Number/toString.js >=================================================================== >--- JSTests/ChakraCore/test/Number/toString.js (revision 246738) >+++ JSTests/ChakraCore/test/Number/toString.js (working copy) >@@ -27,8 +27,8 @@ function runTest(numberToTestAsString) > writeLine("n.toFixed(2): " + n.toFixed(2)); > writeLine("n.toFixed(5): " + n.toFixed(5)); > writeLine("n.toFixed(20): " + n.toFixed(20)); >+ writeLine("n.toFixed(90): " + n.toFixed(90)); > safeCall(function () { n.toFixed(-1); }); >- safeCall(function () { n.toFixed(21); }); > > writeLine("n.toExponential(): " + n.toExponential()); > writeLine("n.toExponential(2): " + n.toExponential(2)); >Index: JSTests/ChakraCore/test/Number/toString_3.baseline-jsc >=================================================================== >--- JSTests/ChakraCore/test/Number/toString_3.baseline-jsc (revision 246738) >+++ JSTests/ChakraCore/test/Number/toString_3.baseline-jsc (working copy) >@@ -10,8 +10,8 @@ n.toFixed(0): 444123 > 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 >+n.toFixed(90): 444123.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 >+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 +32,8 @@ n.toFixed(0): -444123 > 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 >+n.toFixed(90): -444123.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 >+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 +54,8 @@ n.toFixed(0): 444124 > 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 >+n.toFixed(90): 444123.789123456808738410472869873046875000000000000000000000000000000000000000000000000000000000 >+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 +76,8 @@ n.toFixed(0): -444124 > 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 >+n.toFixed(90): -444123.789636363624595105648040771484375000000000000000000000000000000000000000000000000000000000 >+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 +98,8 @@ n.toFixed(0): 0 > 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 >+n.toFixed(90): 0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 >+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 +120,8 @@ n.toFixed(0): 1e+21 > 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 >+n.toFixed(90): 1e+21 >+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 >Index: JSTests/ChakraCore/test/es5/exceptions3.baseline-jsc >=================================================================== >--- JSTests/ChakraCore/test/es5/exceptions3.baseline-jsc (revision 246738) >+++ JSTests/ChakraCore/test/es5/exceptions3.baseline-jsc (working copy) >@@ -21,8 +21,8 @@ undefined.toString(); -expected: es3, > 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 >Index: JSTests/test262/expectations.yaml >=================================================================== >--- JSTests/test262/expectations.yaml (revision 246738) >+++ JSTests/test262/expectations.yaml (working copy) >@@ -1058,15 +1058,6 @@ test/built-ins/Math/round/S15.8.2.15_A7. > 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.' >Index: Source/JavaScriptCore/ChangeLog >=================================================================== >--- Source/JavaScriptCore/ChangeLog (revision 246738) >+++ Source/JavaScriptCore/ChangeLog (working copy) >@@ -1,3 +1,18 @@ >+2019-06-24 Alexey Shvayka <shvaikalesh@gmail.com> >+ >+ toExponential, toFixed, and toPrecision should allow arguments up to 100 >+ https://bugs.webkit.org/show_bug.cgi?id=199163 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ getIntegerArgumentInRange had quite a few arguments and wasn't easy to follow, so I inlined it in methods. >+ >+ * runtime/NumberPrototype.cpp: >+ (JSC::numberProtoFuncToExponential): >+ (JSC::numberProtoFuncToFixed): >+ (JSC::numberProtoFuncToPrecision): >+ (JSC::getIntegerArgumentInRange): Deleted. >+ > 2019-06-22 Robin Morisset <rmorisset@apple.com> and Yusuke Suzuki <ysuzuki@apple.com> > > All prototypes should call didBecomePrototype() >Index: Source/JavaScriptCore/runtime/NumberPrototype.cpp >=================================================================== >--- Source/JavaScriptCore/runtime/NumberPrototype.cpp (revision 246738) >+++ Source/JavaScriptCore/runtime/NumberPrototype.cpp (working copy) >@@ -114,25 +114,6 @@ static ALWAYS_INLINE EncodedJSValue thro > 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 >@@ -415,27 +396,27 @@ EncodedJSValue JSC_HOST_CALL numberProto > 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. > if (!std::isfinite(x)) > return JSValue::encode(jsNontrivialString(exec, 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; > 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(exec, builder.Finalize())); > } > >@@ -452,13 +433,10 @@ EncodedJSValue JSC_HOST_CALL numberProto > 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 >@@ -489,22 +467,20 @@ EncodedJSValue JSC_HOST_CALL numberProto > if (!toThisNumber(vm, exec->thisValue(), x)) > return throwVMToThisNumberError(exec, scope, exec->thisValue()); > >+ JSValue arg = exec->argument(0); >+ if (arg.isUndefined()) >+ return JSValue::encode(jsString(exec, 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(exec, String::number(x))); >- > // Handle NaN and Infinity. > if (!std::isfinite(x)) > return JSValue::encode(jsNontrivialString(exec, 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(exec, String::numberToStringFixedPrecision(x, significantFigures, KeepTrailingZeros))); > } >Index: Source/WTF/ChangeLog >=================================================================== >--- Source/WTF/ChangeLog (revision 246738) >+++ Source/WTF/ChangeLog (working copy) >@@ -1,3 +1,13 @@ >+2019-06-24 Alexey Shvayka <shvaikalesh@gmail.com> >+ >+ toExponential, toFixed, and toPrecision should allow arguments up to 100 >+ https://bugs.webkit.org/show_bug.cgi?id=199163 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * wtf/dtoa.h: Increase size of NumberToStringBuffer to 176. >+ * wtf/dtoa/double-conversion.h: Increase kMaxFixedDigitsAfterPoint to 100. >+ > 2019-06-23 Simon Fraser <simon.fraser@apple.com> > > Add OverflowScrollProxyNodes to the scrolling tree >Index: Source/WTF/wtf/dtoa.h >=================================================================== >--- Source/WTF/wtf/dtoa.h (revision 246738) >+++ Source/WTF/wtf/dtoa.h (working copy) >@@ -27,7 +27,7 @@ > > namespace WTF { > >-using NumberToStringBuffer = std::array<char, 96>; >+using NumberToStringBuffer = std::array<char, 176>; > > WTF_EXPORT_PRIVATE const char* numberToString(float, NumberToStringBuffer&); > WTF_EXPORT_PRIVATE const char* numberToFixedPrecisionString(float, unsigned significantFigures, NumberToStringBuffer&, bool truncateTrailingZeros = false); >Index: Source/WTF/wtf/dtoa/double-conversion.h >=================================================================== >--- Source/WTF/wtf/dtoa/double-conversion.h (revision 246738) >+++ Source/WTF/wtf/dtoa/double-conversion.h (working copy) >@@ -39,7 +39,7 @@ class DoubleToStringConverter { > // or a requested_digits parameter > kMaxFixedDigitsAfterPoint then the > // function returns false. > static const int kMaxFixedDigitsBeforePoint = 60; >- static const int kMaxFixedDigitsAfterPoint = 60; >+ static const int kMaxFixedDigitsAfterPoint = 100; > > // When calling ToExponential with a requested_digits > // parameter > kMaxExponentialDigits then the function returns false. >Index: LayoutTests/ChangeLog >=================================================================== >--- LayoutTests/ChangeLog (revision 246738) >+++ LayoutTests/ChangeLog (working copy) >@@ -1,3 +1,19 @@ >+2019-06-24 Alexey Shvayka <shvaikalesh@gmail.com> >+ >+ toExponential, toFixed, and toPrecision should allow arguments up to 100 >+ https://bugs.webkit.org/show_bug.cgi?id=199163 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * 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-06-24 Greg Doolittle <gr3g@apple.com> > > Web Inspector: AXI: Audit: image label test is throwing spurious errors on elements with existing alt attr, but no value: <img alt> >Index: LayoutTests/js/number-toExponential-expected.txt >=================================================================== >--- LayoutTests/js/number-toExponential-expected.txt (revision 246738) >+++ LayoutTests/js/number-toExponential-expected.txt (working copy) >@@ -17,12 +17,12 @@ PASS (123.456).toExponential(3) is "1.23 > 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" >Index: LayoutTests/js/dom/number-tofixed-expected.txt >=================================================================== >--- LayoutTests/js/dom/number-tofixed-expected.txt (revision 246738) >+++ LayoutTests/js/dom/number-tofixed-expected.txt (working copy) >@@ -42,16 +42,16 @@ PASS (1234.567).toFixed(2) is "1234.57" > 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" >Index: LayoutTests/js/dom/number-toprecision-expected.txt >=================================================================== >--- LayoutTests/js/dom/number-toprecision-expected.txt (revision 246738) >+++ LayoutTests/js/dom/number-toprecision-expected.txt (working copy) >@@ -11,11 +11,11 @@ PASS (-0.0).toPrecision(4) is "0.000" > 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) is "1.2e+ > 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" >Index: LayoutTests/js/dom/script-tests/number-tofixed.js >=================================================================== >--- LayoutTests/js/dom/script-tests/number-tofixed.js (revision 246738) >+++ LayoutTests/js/dom/script-tests/number-tofixed.js (working copy) >@@ -60,10 +60,9 @@ shouldBeEqualToString("(1234.567).toFixe > 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)"); >Index: LayoutTests/js/dom/script-tests/number-toprecision.js >=================================================================== >--- LayoutTests/js/dom/script-tests/number-toprecision.js (revision 246738) >+++ LayoutTests/js/dom/script-tests/number-toprecision.js (working copy) >@@ -28,11 +28,9 @@ shouldBeEqualToString("(1234.567).toPrec > 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 >Index: LayoutTests/js/kde/Number-expected.txt >=================================================================== >--- LayoutTests/js/kde/Number-expected.txt (revision 246738) >+++ LayoutTests/js/kde/Number-expected.txt (working copy) >@@ -63,11 +63,11 @@ PASS Number(-Math.pow(10,21)).toFixed(20 > 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(17) i > 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(17) > 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(17 > 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(1 > 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).toE > 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).to > 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 Number(-123456789012345678901.2).to > 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" >Index: LayoutTests/js/kde/script-tests/Number.js >=================================================================== >--- LayoutTests/js/kde/script-tests/Number.js (revision 246738) >+++ LayoutTests/js/kde/script-tests/Number.js (working copy) >@@ -74,11 +74,11 @@ shouldBe("Number(-Math.pow(10,21)).toFix > 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( > 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 > 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).toExponenti > 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).toExponent > 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 > 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.456789012345678901 > 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 @@ shouldBe("Number(-123456789012345678901. > 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\""); >Index: LayoutTests/js/script-tests/number-toExponential.js >=================================================================== >--- LayoutTests/js/script-tests/number-toExponential.js (revision 246738) >+++ LayoutTests/js/script-tests/number-toExponential.js (working copy) >@@ -27,10 +27,9 @@ shouldBeEqualToString("(123.456).toExpon > 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)"); >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 199163
:
372768
|
379449
|
379502
|
379651