diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Array/prototype/unshift/throws-if-integer-limit-exceeded.js')
-rw-r--r-- | js/src/tests/test262/built-ins/Array/prototype/unshift/throws-if-integer-limit-exceeded.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Array/prototype/unshift/throws-if-integer-limit-exceeded.js b/js/src/tests/test262/built-ins/Array/prototype/unshift/throws-if-integer-limit-exceeded.js new file mode 100644 index 0000000000..0e9ceada82 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/throws-if-integer-limit-exceeded.js @@ -0,0 +1,40 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.unshift +description: > + A TypeError is thrown if the new length exceeds 2^53-1. +info: | + 1. ... + 2. Let len be ? ToLength(? Get(O, "length")). + 3. Let argCount be the number of actual arguments. + 4. If argCount > 0, then + a. If len+argCount > 2^53-1, throw a TypeError exception. + b. ... +features: [exponentiation] +---*/ + +var arrayLike = {}; + +arrayLike.length = 2 ** 53 - 1; +assert.throws(TypeError, function() { + Array.prototype.unshift.call(arrayLike, null); +}, "Length is 2**53 - 1"); + +arrayLike.length = 2 ** 53; +assert.throws(TypeError, function() { + Array.prototype.unshift.call(arrayLike, null); +}, "Length is 2**53"); + +arrayLike.length = 2 ** 53 + 2; +assert.throws(TypeError, function() { + Array.prototype.unshift.call(arrayLike, null); +}, "Length is 2**53 + 2"); + +arrayLike.length = Infinity; +assert.throws(TypeError, function() { + Array.prototype.unshift.call(arrayLike, null); +}, "Length is Infinity"); + +reportCompare(0, 0); |