iterator-next-failure.js (627B)
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 esid: sec-map-iterable 5 description: > 6 The iterator is closed when iterable `next` throws an error. 7 info: | 8 Map ( [ iterable ] ) 9 10 ... 11 9. Repeat 12 a. Let next be IteratorStep(iter). 13 b. ReturnIfAbrupt(next). 14 features: [Symbol.iterator] 15 ---*/ 16 17 var iterable = {}; 18 iterable[Symbol.iterator] = function() { 19 return { 20 next: function() { 21 throw new Test262Error(); 22 } 23 }; 24 }; 25 26 assert.throws(Test262Error, function() { 27 new Map(iterable); 28 }); 29 30 reportCompare(0, 0);