Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/async-generator/yield-star-getiter-sync-not-callable-object-throw.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/async-generators/yield-star-getiter-sync-not-callable-object-throw.case
3 // - src/async-generators/default/async-expression.template
4 /*---
5 description: Throws a TypeError on a non-callable [Symbol.iterator] (object) (Unnamed async generator expression)
6 esid: prod-AsyncGeneratorExpression
7 features: [Symbol.iterator, async-iteration]
8 flags: [generated, async]
9 info: |
10 Async Generator Function Definitions
11
12 AsyncGeneratorExpression :
13 async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) {
14 AsyncGeneratorBody }
15
16
17 YieldExpression: yield * AssignmentExpression
18
19 1. Let exprRef be the result of evaluating AssignmentExpression.
20 2. Let value be ? GetValue(exprRef).
21 3. Let generatorKind be ! GetGeneratorKind().
22 4. Let iterator be ? GetIterator(value, generatorKind).
23 ...
24
25 GetIterator ( obj [ , hint ] )
26
27 ...
28 3. If hint is async,
29 a. Set method to ? GetMethod(obj, @@asyncIterator).
30 b. If method is undefined,
31 i. Let syncMethod be ? GetMethod(obj, @@iterator).
32 ...
33
34 GetMethod ( V, P )
35
36 ...
37 2. Let func be ? GetV(V, P).
38 ...
39 4. If IsCallable(func) is false, throw a TypeError exception.
40 ...
41
42 ---*/
43 var obj = {
44 [Symbol.iterator]: {}
45 };
46
47
48
49 var callCount = 0;
50
51 var gen = async function *() {
52 callCount += 1;
53 yield* obj;
54 throw new Test262Error('abrupt completion closes iter');
55
56 };
57
58 var iter = gen();
59
60 iter.next().then(() => {
61 throw new Test262Error('Promise incorrectly fulfilled.');
62 }, v => {
63 assert.sameValue(v.constructor, TypeError, "TypeError");
64
65 iter.next().then(({ done, value }) => {
66 assert.sameValue(done, true, 'the iterator is completed');
67 assert.sameValue(value, undefined, 'value is undefined');
68 }).then($DONE, $DONE);
69 }).catch($DONE);
70
71 assert.sameValue(callCount, 1);