summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Array/toSpliced.js
blob: 7c8faf917bfa67f878ab0196f0cddb9a859cfd6f (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
// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.toSpliced)

Object.defineProperty(Array.prototype, 0, {
  set() {
    throw "bad 0";
  },
});

Object.defineProperty(Array.prototype, 1, {
  set() {
    throw "bad 1";
  },
});

assertDeepEq([].toSpliced(0, 0, 1), [1]);

assertDeepEq([0].toSpliced(0, 0, 0), [0, 0]);
assertDeepEq([0].toSpliced(0, 0, 1), [1, 0]);
assertDeepEq([0].toSpliced(0, 1, 0), [0]);
assertDeepEq([0].toSpliced(0, 1, 1), [1]);
assertDeepEq([0].toSpliced(1, 0, 0), [0, 0]);
assertDeepEq([0].toSpliced(1, 0, 1), [0, 1]);
assertDeepEq([0].toSpliced(1, 1, 0), [0, 0]);
assertDeepEq([0].toSpliced(1, 1, 1), [0, 1]);

if (typeof reportCompare === "function")
  reportCompare(0, 0);