array-key-get-error.js (694B)
1 // Copyright (C) 2015 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 description: Error in Array entry access during traversal using for..of 6 info: | 7 If retrieving an element from the array produces an error, that error 8 should be forwarded to the run time. 9 es6id: 13.6.4 10 ---*/ 11 12 var array = []; 13 var iterationCount = 0; 14 15 Object.defineProperty(array, '0', { 16 get: function() { 17 throw new Test262Error(); 18 } 19 }); 20 21 assert.throws(Test262Error, function() { 22 for (var value of array) { 23 iterationCount += 1; 24 } 25 }); 26 27 assert.sameValue(iterationCount, 0, 'The loop body is not evaluated'); 28 29 reportCompare(0, 0);