diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /js/src/tests/ecma_3/Number | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/tests/ecma_3/Number')
-rw-r--r-- | js/src/tests/ecma_3/Number/15.7.4.2-01.js | 44 | ||||
-rw-r--r-- | js/src/tests/ecma_3/Number/15.7.4.3-01.js | 36 | ||||
-rw-r--r-- | js/src/tests/ecma_3/Number/15.7.4.5-1.js | 111 | ||||
-rw-r--r-- | js/src/tests/ecma_3/Number/15.7.4.5-2.js | 29 | ||||
-rw-r--r-- | js/src/tests/ecma_3/Number/15.7.4.6-1.js | 115 | ||||
-rw-r--r-- | js/src/tests/ecma_3/Number/15.7.4.7-1.js | 120 | ||||
-rw-r--r-- | js/src/tests/ecma_3/Number/15.7.4.7-2.js | 39 | ||||
-rw-r--r-- | js/src/tests/ecma_3/Number/browser.js | 0 | ||||
-rw-r--r-- | js/src/tests/ecma_3/Number/regress-442242-01.js | 29 | ||||
-rw-r--r-- | js/src/tests/ecma_3/Number/shell.js | 0 |
10 files changed, 523 insertions, 0 deletions
diff --git a/js/src/tests/ecma_3/Number/15.7.4.2-01.js b/js/src/tests/ecma_3/Number/15.7.4.2-01.js new file mode 100644 index 000000000..a2cc265e1 --- /dev/null +++ b/js/src/tests/ecma_3/Number/15.7.4.2-01.js @@ -0,0 +1,44 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = "411889"; +var summary = "num.toString(), num.toString(10), and num.toString(undefined)" + + " should all be equivalent"; +var actual, expect; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +/************** + * BEGIN TEST * + **************/ + +var failed = false; + +try +{ + var noargs = 3.3.toString(); + var tenarg = 3.3.toString(10); + var undefarg = 3.3.toString(undefined); + + if (noargs !== tenarg) + throw "() !== (10): " + noargs + " !== " + tenarg; + if (tenarg !== undefarg) + throw "(10) !== (undefined): " + tenarg + " !== " + undefarg; +} +catch (e) +{ + failed = e; +} + +expect = false; +actual = failed; + +reportCompare(expect, actual, summary); + +expect = 1; +actual = 3.3.toString.length; +reportCompare(expect, actual, '3.3.toString.length should be 1'); diff --git a/js/src/tests/ecma_3/Number/15.7.4.3-01.js b/js/src/tests/ecma_3/Number/15.7.4.3-01.js new file mode 100644 index 000000000..2f1f3fffc --- /dev/null +++ b/js/src/tests/ecma_3/Number/15.7.4.3-01.js @@ -0,0 +1,36 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = "412068"; +var summary = "num.toLocaleString incorrectly accesses its first argument " + + "even when no first argument has been given"; +var actual, expect; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +/************** + * BEGIN TEST * + **************/ + +var failed = false; + +try +{ + if ("3" !== 3..toLocaleString()) + throw '"3" should equal 3..toLocaleString()'; + if ("9" !== 9..toLocaleString(8)) + throw 'Number.prototype.toLocaleString should ignore its first argument'; +} +catch (e) +{ + failed = e; +} + +expect = false; +actual = failed; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/ecma_3/Number/15.7.4.5-1.js b/js/src/tests/ecma_3/Number/15.7.4.5-1.js new file mode 100644 index 000000000..ab7f356c6 --- /dev/null +++ b/js/src/tests/ecma_3/Number/15.7.4.5-1.js @@ -0,0 +1,111 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 2001-07-15 + * + * SUMMARY: Testing Number.prototype.toFixed(fractionDigits) + * See EMCA 262 Edition 3 Section 15.7.4.5 + * + * Also see http://bugzilla.mozilla.org/show_bug.cgi?id=90551 + * + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = '(none)'; +var summary = 'Testing Number.prototype.toFixed(fractionDigits)'; +var cnIsRangeError = 'instanceof RangeError'; +var cnNotRangeError = 'NOT instanceof RangeError'; +var cnNoErrorCaught = 'NO ERROR CAUGHT...'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var testNum = 234.2040506; + + +status = 'Section A of test: no error intended!'; +actual = testNum.toFixed(4); +expect = '234.2041'; +captureThis(); + + +/////////////////////////// OOPS.... /////////////////////////////// +/************************************************************************* + * 15.7.4.5 Number.prototype.toFixed(fractionDigits) + * + * An implementation is permitted to extend the behaviour of toFixed + * for values of fractionDigits less than 0 or greater than 20. In this + * case toFixed would not necessarily throw RangeError for such values. + +status = 'Section B of test: expect RangeError because fractionDigits < 0'; +actual = catchError('testNum.toFixed(-4)'); +expect = cnIsRangeError; +captureThis(); + +status = 'Section C of test: expect RangeError because fractionDigits > 20 '; +actual = catchError('testNum.toFixed(21)'); +expect = cnIsRangeError; +captureThis(); +*************************************************************************/ + + +status = 'Section D of test: no error intended!'; +actual = 0.00001.toFixed(2); +expect = '0.00'; +captureThis(); + +status = 'Section E of test: no error intended!'; +actual = 0.000000000000000000001.toFixed(20); +expect = '0.00000000000000000000'; +captureThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + +function captureThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } + + exitFunc ('test'); +} + + +function catchError(sEval) +{ + try {eval(sEval);} + catch(e) {return isRangeError(e);} + return cnNoErrorCaught; +} + + +function isRangeError(obj) +{ + if (obj instanceof RangeError) + return cnIsRangeError; + return cnNotRangeError; +} diff --git a/js/src/tests/ecma_3/Number/15.7.4.5-2.js b/js/src/tests/ecma_3/Number/15.7.4.5-2.js new file mode 100644 index 000000000..f9c75ea15 --- /dev/null +++ b/js/src/tests/ecma_3/Number/15.7.4.5-2.js @@ -0,0 +1,29 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 469397; +var summary = '(0.5).toFixed(0) == 1'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = '1'; + actual = (0.5).toFixed(0); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/Number/15.7.4.6-1.js b/js/src/tests/ecma_3/Number/15.7.4.6-1.js new file mode 100644 index 000000000..df45fa2ac --- /dev/null +++ b/js/src/tests/ecma_3/Number/15.7.4.6-1.js @@ -0,0 +1,115 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 2001-07-15 + * + * SUMMARY: Testing Number.prototype.toExponential(fractionDigits) + * See EMCA 262 Edition 3 Section 15.7.4.6 + * + * Also see http://bugzilla.mozilla.org/show_bug.cgi?id=90551 + * + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = '(none)'; +var summary = 'Testing Number.prototype.toExponential(fractionDigits)'; +var cnIsRangeError = 'instanceof RangeError'; +var cnNotRangeError = 'NOT instanceof RangeError'; +var cnNoErrorCaught = 'NO ERROR CAUGHT...'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var testNum = 77.1234; + + +status = 'Section A of test: no error intended!'; +actual = testNum.toExponential(4); +expect = '7.7123e+1'; +captureThis(); + +status = 'Section B of test: Infinity.toExponential() with out-of-range fractionDigits'; +actual = Number.POSITIVE_INFINITY.toExponential(-3); +expect = 'Infinity'; +captureThis(); + +status = 'Section C of test: -Infinity.toExponential() with out-of-range fractionDigits'; +actual = Number.NEGATIVE_INFINITY.toExponential(-3); +expect = '-Infinity'; +captureThis(); + +status = 'Section D of test: NaN.toExponential() with out-of-range fractionDigits'; +actual = Number.NaN.toExponential(-3); +expect = 'NaN'; +captureThis(); + + +/////////////////////////// OOPS.... /////////////////////////////// +/************************************************************************* + * 15.7.4.6 Number.prototype.toExponential(fractionDigits) + * + * An implementation is permitted to extend the behaviour of toExponential + * for values of fractionDigits less than 0 or greater than 20. In this + * case toExponential would not necessarily throw RangeError for such values. + +status = 'Section B of test: expect RangeError because fractionDigits < 0'; +actual = catchError('testNum.toExponential(-4)'); +expect = cnIsRangeError; +captureThis(); + +status = 'Section C of test: expect RangeError because fractionDigits > 20 '; +actual = catchError('testNum.toExponential(21)'); +expect = cnIsRangeError; +captureThis(); +*************************************************************************/ + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + +function captureThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } + + exitFunc ('test'); +} + + +function catchError(sEval) +{ + try {eval(sEval);} + catch(e) {return isRangeError(e);} + return cnNoErrorCaught; +} + + +function isRangeError(obj) +{ + if (obj instanceof RangeError) + return cnIsRangeError; + return cnNotRangeError; +} diff --git a/js/src/tests/ecma_3/Number/15.7.4.7-1.js b/js/src/tests/ecma_3/Number/15.7.4.7-1.js new file mode 100644 index 000000000..e754528d5 --- /dev/null +++ b/js/src/tests/ecma_3/Number/15.7.4.7-1.js @@ -0,0 +1,120 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 2001-07-15 + * + * SUMMARY: Testing Number.prototype.toPrecision(precision) + * See EMCA 262 Edition 3 Section 15.7.4.7 + * + * Also see http://bugzilla.mozilla.org/show_bug.cgi?id=90551 + * + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = '(none)'; +var summary = 'Testing Number.prototype.toPrecision(precision)'; +var cnIsRangeError = 'instanceof RangeError'; +var cnNotRangeError = 'NOT instanceof RangeError'; +var cnNoErrorCaught = 'NO ERROR CAUGHT...'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var testNum = 5.123456; + + +status = 'Section A of test: no error intended!'; +actual = testNum.toPrecision(4); +expect = '5.123'; +captureThis(); + +status = 'Section B of test: Infinity.toPrecision() with out-of-range fractionDigits'; +actual = Number.POSITIVE_INFINITY.toPrecision(-3); +expect = 'Infinity'; +captureThis(); + +status = 'Section C of test: -Infinity.toPrecision() with out-of-range fractionDigits'; +actual = Number.NEGATIVE_INFINITY.toPrecision(-3); +expect = '-Infinity'; +captureThis(); + +status = 'Section D of test: NaN.toPrecision() with out-of-range fractionDigits'; +actual = Number.NaN.toPrecision(-3); +expect = 'NaN'; +captureThis(); + + +/////////////////////////// OOPS.... /////////////////////////////// +/************************************************************************* + * 15.7.4.7 Number.prototype.toPrecision(precision) + * + * An implementation is permitted to extend the behaviour of toPrecision + * for values of precision less than 1 or greater than 21. In this + * case toPrecision would not necessarily throw RangeError for such values. + +status = 'Section B of test: expect RangeError because precision < 1'; +actual = catchError('testNum.toPrecision(0)'); +expect = cnIsRangeError; +captureThis(); + +status = 'Section C of test: expect RangeError because precision < 1'; +actual = catchError('testNum.toPrecision(-4)'); +expect = cnIsRangeError; +captureThis(); + +status = 'Section D of test: expect RangeError because precision > 21 '; +actual = catchError('testNum.toPrecision(22)'); +expect = cnIsRangeError; +captureThis(); +*************************************************************************/ + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + +function captureThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } + + exitFunc ('test'); +} + + +function catchError(sEval) +{ + try {eval(sEval);} + catch(e) {return isRangeError(e);} + return cnNoErrorCaught; +} + + +function isRangeError(obj) +{ + if (obj instanceof RangeError) + return cnIsRangeError; + return cnNotRangeError; +} diff --git a/js/src/tests/ecma_3/Number/15.7.4.7-2.js b/js/src/tests/ecma_3/Number/15.7.4.7-2.js new file mode 100644 index 000000000..6845b3087 --- /dev/null +++ b/js/src/tests/ecma_3/Number/15.7.4.7-2.js @@ -0,0 +1,39 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = "411893"; +var summary = "num.toPrecision(undefined) should equal num.toString()"; +var actual, expect; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +/************** + * BEGIN TEST * + **************/ + +var failed = false; + +try +{ + var prec = 3.3.toPrecision(undefined); + var str = 3.3.toString(); + if (prec !== str) + { + throw "not equal! " + + "3.3.toPrecision(undefined) === '" + prec + "', " + + "3.3.toString() === '" + str + "'"; + } +} +catch (e) +{ + failed = e; +} + +expect = false; +actual = failed; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/ecma_3/Number/browser.js b/js/src/tests/ecma_3/Number/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/ecma_3/Number/browser.js diff --git a/js/src/tests/ecma_3/Number/regress-442242-01.js b/js/src/tests/ecma_3/Number/regress-442242-01.js new file mode 100644 index 000000000..5202c004f --- /dev/null +++ b/js/src/tests/ecma_3/Number/regress-442242-01.js @@ -0,0 +1,29 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 442242; +var summary = 'Do not assert: INT_FITS_IN_JSVAL(i)'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var i = 28800000; + -i; + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/Number/shell.js b/js/src/tests/ecma_3/Number/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/ecma_3/Number/shell.js |