summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Array/prototype/concat/arg-length-exceeding-integer-limit.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/Array/prototype/concat/arg-length-exceeding-integer-limit.js')
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/concat/arg-length-exceeding-integer-limit.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/arg-length-exceeding-integer-limit.js b/js/src/tests/test262/built-ins/Array/prototype/concat/arg-length-exceeding-integer-limit.js
new file mode 100644
index 0000000000..3e997498e9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/concat/arg-length-exceeding-integer-limit.js
@@ -0,0 +1,42 @@
+// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.concat
+description: >
+ TypeError is thrown if "length" of result array exceeds 2^53 - 1.
+info: |
+ Array.prototype.concat ( ...arguments )
+
+ [...]
+ 5. Repeat, while items is not empty
+ [...]
+ c. If spreadable is true, then
+ [...]
+ ii. Let len be ? LengthOfArrayLike(E).
+ iii. If n + len > 2^53 - 1, throw a TypeError exception.
+ [...]
+features: [Symbol.isConcatSpreadable, Proxy]
+---*/
+
+var spreadableLengthOutOfRange = {};
+spreadableLengthOutOfRange.length = Number.MAX_SAFE_INTEGER;
+spreadableLengthOutOfRange[Symbol.isConcatSpreadable] = true;
+
+assert.throws(TypeError, function() {
+ [1].concat(spreadableLengthOutOfRange);
+}, '[1].concat(spreadableLengthOutOfRange) throws a TypeError exception');
+
+var proxyForArrayWithLengthOutOfRange = new Proxy([], {
+ get: function(_target, key) {
+ if (key === "length") {
+ return Number.MAX_SAFE_INTEGER;
+ }
+ },
+});
+
+assert.throws(TypeError, function() {
+ [].concat(1, proxyForArrayWithLengthOutOfRange);
+}, '[].concat(1, proxyForArrayWithLengthOutOfRange) throws a TypeError exception');
+
+reportCompare(0, 0);