iterator-not-closed-for-uncallable-next.js (1115B)
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 an uncallable `next` property. 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 features: [Symbol.iterator, Object.fromEntries] 26 ---*/ 27 28 var iterable = { 29 [Symbol.iterator]: function() { 30 return { 31 next: null, 32 return: function() { 33 throw new Test262Error('should not call return'); 34 }, 35 }; 36 }, 37 }; 38 39 assert.sameValue(typeof Object.fromEntries, 'function'); 40 assert.throws(TypeError, function() { 41 Object.fromEntries(iterable); 42 }); 43 44 reportCompare(0, 0);