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/js1_5/Array/regress-465980-02.js | |
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/js1_5/Array/regress-465980-02.js')
-rwxr-xr-x | js/src/tests/js1_5/Array/regress-465980-02.js | 170 |
1 files changed, 170 insertions, 0 deletions
diff --git a/js/src/tests/js1_5/Array/regress-465980-02.js b/js/src/tests/js1_5/Array/regress-465980-02.js new file mode 100755 index 000000000..08bab06d4 --- /dev/null +++ b/js/src/tests/js1_5/Array/regress-465980-02.js @@ -0,0 +1,170 @@ +// |reftest| skip -- slow +/* -*- 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/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 465980; +var summary = 'Do not crash @ InitArrayElements'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + function describe(name, startLength, pushArgs, expectThrow, expectLength) + { + return name + "(" + startLength + ", " + + "[" + pushArgs.join(", ") + "], " + + expectThrow + ", " + + expectLength + ")"; + } + + var push = Array.prototype.push; + var unshift = Array.prototype.unshift; + + function testArrayPush(startLength, pushArgs, expectThrow, expectLength) + { + print("running testArrayPush(" + + startLength + ", " + + "[" + pushArgs.join(", ") + "], " + + expectThrow + ", " + + expectLength + ")..."); + var a = new Array(startLength); + try + { + push.apply(a, pushArgs); + if (expectThrow) + { + throw "expected to throw for " + + describe("testArrayPush", startLength, pushArgs, expectThrow, + expectLength); + } + } + catch (e) + { + if (!(e instanceof RangeError)) + { + throw "unexpected exception type thrown: " + e + " for " + + describe("testArrayPush", startLength, pushArgs, expectThrow, + expectLength); + } + if (!expectThrow) + { + throw "unexpected exception " + e + " for " + + describe("testArrayPush", startLength, pushArgs, expectThrow, + expectLength); + } + } + + if (a.length !== expectLength) + { + throw "unexpected modified-array length for " + + describe("testArrayPush", startLength, pushArgs, expectThrow, + expectLength); + } + + for (var i = 0, sz = pushArgs.length; i < sz; i++) + { + var index = i + startLength; + if (a[index] !== pushArgs[i]) + { + throw "unexpected value " + a[index] + + " at index " + index + " (" + i + ") during " + + describe("testArrayPush", startLength, pushArgs, expectThrow, + expectLength) + ", expected " + pushArgs[i]; + } + } + } + + function testArrayUnshift(startLength, unshiftArgs, expectThrow, expectLength) + { + print("running testArrayUnshift(" + + startLength + ", " + + "[" + unshiftArgs.join(", ") + "], " + + expectThrow + ", " + + expectLength + ")..."); + var a = new Array(startLength); + try + { + unshift.apply(a, unshiftArgs); + if (expectThrow) + { + throw "expected to throw for " + + describe("testArrayUnshift", startLength, unshiftArgs, expectThrow, + expectLength); + } + } + catch (e) + { + if (!(e instanceof RangeError)) + { + throw "unexpected exception type thrown: " + e + " for " + + describe("testArrayUnshift", startLength, unshiftArgs, expectThrow, + expectLength); + } + if (!expectThrow) + { + throw "unexpected exception " + e + " for " + + describe("testArrayUnshift", startLength, unshiftArgs, expectThrow, + expectLength); + } + } + + if (a.length !== expectLength) + { + throw "unexpected modified-array length for " + + describe("testArrayUnshift", startLength, unshiftArgs, expectThrow, + expectLength); + } + + for (var i = 0, sz = unshiftArgs.length; i < sz; i++) + { + if (a[i] !== unshiftArgs[i]) + { + throw "unexpected value at index " + i + " during " + + describe("testArrayUnshift", startLength, unshiftArgs, expectThrow, + expectLength); + } + } + } + + var failed = true; + + try + { + var foo = "foo", bar = "bar", baz = "baz"; + + testArrayPush(4294967294, [foo], false, 4294967295); + testArrayPush(4294967294, [foo, bar], true, 4294967295); + testArrayPush(4294967294, [foo, bar, baz], true, 4294967295); + testArrayPush(4294967295, [foo], true, 4294967295); + testArrayPush(4294967295, [foo, bar], true, 4294967295); + testArrayPush(4294967295, [foo, bar, baz], true, 4294967295); + + testArrayUnshift(4294967294, [foo], false, 4294967295); + testArrayUnshift(4294967294, [foo, bar], true, 4294967294); + testArrayUnshift(4294967294, [foo, bar, baz], true, 4294967294); + testArrayUnshift(4294967295, [foo], true, 4294967295); + testArrayUnshift(4294967295, [foo, bar], true, 4294967295); + testArrayUnshift(4294967295, [foo, bar, baz], true, 4294967295); + + } + catch (e) + { + actual = e + ''; + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} |