blob: 433aa3b06641537387a4fd4e2d008b070de05863 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
load("test-common.js");
function testArray(arr) {
return arr.length === 4 &&
arr[0] === "a" &&
arr[1] === "b" &&
arr[2] === "c" &&
arr[3] === "d";
}
try {
var arr;
arr = ["a", ..."bc", "d"];
assert(testArray(arr));
let s = "bc";
arr = ["a", ...s, "d"];
assert(testArray(arr));
let obj = { a: "bc" };
arr = ["a", ...obj.a, "d"];
assert(testArray(arr));
arr = [..."", ...[...new String("abc")], "d"];
assert(testArray(arr));
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
|