iterator-not-closed-for-throwing-next.js (1253B)
1 // Copyright (C) 2018 Kevin Gibbons. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 esid: sec-object.fromentries 6 description: Does not close iterators with a `next` method which throws. 7 info: | 8 Object.fromEntries ( iterable ) 9 10 ... 11 4. Let stepsDefine be the algorithm steps defined in CreateDataPropertyOnObject Functions. 12 5. Let adder be CreateBuiltinFunction(stepsDefine, « »). 13 6. Return ? AddEntriesFromIterable(obj, iterable, adder). 14 15 AddEntriesFromIterable ( target, iterable, adder ) 16 17 ... 18 4. Repeat, 19 a. Let next be ? IteratorStep(iteratorRecord). 20 21 22 IteratorStep ( iteratorRecord ) 23 24 1. Let result be ? IteratorNext(iteratorRecord). 25 26 27 IteratorNext ( iteratorRecord [ , value ] ) 28 29 ... 30 3. If Type(result) is not Object, throw a TypeError exception. 31 32 features: [Symbol.iterator, Object.fromEntries] 33 ---*/ 34 35 function DummyError() {} 36 37 var iterable = { 38 [Symbol.iterator]: function() { 39 return { 40 next: function() { 41 throw new DummyError(); 42 }, 43 return: function() { 44 throw new Test262Error('should not call return'); 45 }, 46 }; 47 }, 48 }; 49 50 assert.throws(DummyError, function() { 51 Object.fromEntries(iterable); 52 }); 53 54 reportCompare(0, 0);