summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/basic/spread-array.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /js/src/jit-test/tests/basic/spread-array.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-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/jit-test/tests/basic/spread-array.js')
-rw-r--r--js/src/jit-test/tests/basic/spread-array.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/basic/spread-array.js b/js/src/jit-test/tests/basic/spread-array.js
new file mode 100644
index 000000000..30d4cb52b
--- /dev/null
+++ b/js/src/jit-test/tests/basic/spread-array.js
@@ -0,0 +1,50 @@
+load(libdir + "asserts.js");
+load(libdir + "iteration.js");
+load(libdir + "eqArrayHelper.js");
+
+assertEqArray([...[1, 2, 3]], [1, 2, 3]);
+assertEqArray([1, ...[2, 3, 4], 5], [1, 2, 3, 4, 5]);
+assertEqArray([1, ...[], 2], [1, 2]);
+assertEqArray([1, ...[2, 3], 4, ...[5, 6]], [1, 2, 3, 4, 5, 6]);
+assertEqArray([1, ...[], 2], [1, 2]);
+assertEqArray([1,, ...[2]], [1,, 2]);
+assertEqArray([1,, ...[2],, 3,, 4,], [1,, 2,, 3,, 4,]);
+assertEqArray([...[1, 2, 3],,,,], [1, 2, 3,,,,]);
+assertEqArray([,,...[1, 2, 3],,,,], [,,1,2,3,,,,]);
+assertEqArray([...[1, 2, 3],,,,...[]], [1,2,3,,,,]);
+
+assertEqArray([...[undefined]], [undefined]);
+
+// other iterable objects
+assertEqArray([...new Int32Array([1, 2, 3])], [1, 2, 3]);
+assertEqArray([..."abc"], ["a", "b", "c"]);
+assertEqArray([...[1, 2, 3][Symbol.iterator]()], [1, 2, 3]);
+assertEqArray([...new Set([1, 2, 3])], [1, 2, 3]);
+assertEqArray([...new Map([["a", "A"], ["b", "B"], ["c", "C"]])].map(([k, v]) => k + v), ["aA", "bB", "cC"]);
+let itr = {};
+itr[Symbol.iterator] = function () {
+ return {
+ i: 1,
+ next: function() {
+ if (this.i < 4)
+ return { value: this.i++, done: false };
+ else
+ return { value: undefined, done: true };
+ }
+ };
+}
+assertEqArray([...itr], [1, 2, 3]);
+function* gen() {
+ for (let i = 1; i < 4; i ++)
+ yield i;
+}
+assertEqArray([...gen()], [1, 2, 3]);
+
+let a, b = [1, 2, 3];
+assertEqArray([...a=b], [1, 2, 3]);
+
+// 12.2.4.1.2 Runtime Semantics: ArrayAccumulation
+// If Type(spreadObj) is not Object, then throw a TypeError exception.
+assertThrowsInstanceOf(() => [...null], TypeError);
+assertThrowsInstanceOf(() => [...undefined], TypeError);
+