summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/warp/store-element-hole-negative-index.js
blob: 43d017769c83e188551a768b2050178a6ed3f09e (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
function test() {
  Object.defineProperty(Array.prototype, -1, {
    set() {
      throw new Error("shouldn't get here");
    }
  });

  // A bunch of indices which grow the array.
  var indices = [];
  for (var i = 0; i < 10_000; ++i) indices.push(i);

  // And finally a negative index.
  indices.push(-1);

  // Plain data properties use DefineDataProperty.
  var desc = {value: 0, writable: true, enumerable: true, configurable: true};

  var a = [];
  for (var i = 0; i < indices.length; ++i) {
    Object.defineProperty(a, indices[i], desc);
  }
}

test();