throw.js (824B)
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 es6id: 13.6.4.13 5 description: > 6 Control flow during body evaluation should honor `throw` statements. 7 features: [generators] 8 ---*/ 9 10 function* values() { 11 yield 1; 12 throw new Test262Error('This code is unreachable (following `yield` statement).'); 13 } 14 var CustomError = function() {}; 15 var iterator = values(); 16 var i = 0; 17 var error = new CustomError(); 18 19 assert.throws(CustomError, function() { 20 for (var x of iterator) { 21 i++; 22 throw error; 23 24 throw new Test262Error('This code is unreachable (following `throw` statement).'); 25 } 26 27 throw new Test262Error('This code is unreachable (following `for..in` statement).'); 28 }); 29 30 assert.sameValue(i, 1); 31 32 reportCompare(0, 0);