summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Array/with.js
blob: a50fba74c09ea86d5d30c083d0c038bf8d1d6460 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with)

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

// Single element case.
assertDeepEq([0].with(0, 1), [1]);

// More than one element.
assertDeepEq([1, 2].with(0, 3), [3, 2]);
assertDeepEq([1, 2].with(1, 3), [1, 3]);

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