Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/class/async-gen-method-yield-star-getiter-async-not-callable-symbol-throw.js

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