summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Array/prototype/includes/return-abrupt-get-prop.js
blob: 14b1a49d471a2dfca47177e92b0bb5acf4622807 (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
32
33
34
35
36
37
38
39
40
41
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-array.prototype.includes
description: Return abrupt getting index properties
info: |
  22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] )

  ...
  7. Repeat, while k < len
    a. Let elementK be the result of ? Get(O, ! ToString(k)).
  ...
features: [Array.prototype.includes]
---*/

var stopped = 0;

var obj = {
  length: 3
};

Object.defineProperty(obj, "1", {
  get: function() {
    throw new Test262Error();
  }
});

Object.defineProperty(obj, "2", {
  get: function() {
    stopped++;
  }
});

assert.throws(Test262Error, function() {
  [].includes.call(obj, 7);
});

assert.sameValue(stopped, 0, "It stops the loop after the abrupt completion");

reportCompare(0, 0);