Debian Codegraph @

js/src/tests/test262/built-ins/Object/fromEntries/iterator-not-closed-for-throwing-done-accessor.js

raw
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 `done` accessor 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 returned = false;
38 var iterable = {
39 [Symbol.iterator]: function() {
40 return {
41 next: function() {
42 return {
43 get done() {
44 throw new DummyError();
45 },
46 };
47 },
48 return: function() {
49 throw new Test262Error('should not call return');
50 },
51 };
52 },
53 };
54
55 assert.throws(DummyError, function() {
56 Object.fromEntries(iterable);
57 });
58
59 reportCompare(0, 0);