summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/statements/for-of/array-key-get-error.js
blob: aef1e6a3cd8595211f4abdece284389d2e2b4070 (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
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: Error in Array entry access during traversal using for..of
info: |
    If retrieving an element from the array produces an error, that error
    should be forwarded to the run time.
es6id: 13.6.4
---*/

var array = [];
var iterationCount = 0;

Object.defineProperty(array, '0', {
  get: function() {
    throw new Test262Error();
  }
});

assert.throws(Test262Error, function() {
  for (var value of array) {
    iterationCount += 1;
  }
});

assert.sameValue(iterationCount, 0, 'The loop body is not evaluated');

reportCompare(0, 0);