Debian Codegraph @

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

raw
1 // This file was procedurally generated from the following sources:
2 // - src/async-generators/yield-star-getiter-sync-not-callable-string-throw.case
3 // - src/async-generators/default/async-obj-method.template
4 /*---
5 description: Throws a TypeError on a non-callable [Symbol.iterator] (string) (Async generator method)
6 esid: prod-AsyncGeneratorMethod
7 features: [Symbol.iterator, async-iteration]
8 flags: [generated, async]
9 info: |
10 Async Generator Function Definitions
11
12 AsyncGeneratorMethod :
13 async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody }
14
15
16 YieldExpression: yield * AssignmentExpression
17
18 1. Let exprRef be the result of evaluating AssignmentExpression.
19 2. Let value be ? GetValue(exprRef).
20 3. Let generatorKind be ! GetGeneratorKind().
21 4. Let iterator be ? GetIterator(value, generatorKind).
22 ...
23
24 GetIterator ( obj [ , hint ] )
25
26 ...
27 3. If hint is async,
28 a. Set method to ? GetMethod(obj, @@asyncIterator).
29 b. If method is undefined,
30 i. Let syncMethod be ? GetMethod(obj, @@iterator).
31 ...
32
33 GetMethod ( V, P )
34
35 ...
36 2. Let func be ? GetV(V, P).
37 ...
38 4. If IsCallable(func) is false, throw a TypeError exception.
39 ...
40
41 ---*/
42 var obj = {
43 [Symbol.iterator]: ''
44 };
45
46
47 var callCount = 0;
48
49 var gen = {
50 async *method() {
51 callCount += 1;
52 yield* obj;
53 throw new Test262Error('abrupt completion closes iter');
54
55 }
56 }.method;
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);