Debian Codegraph @

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

raw
1 // This file was procedurally generated from the following sources:
2 // - src/async-generators/yield-star-getiter-async-not-callable-object-throw.case
3 // - src/async-generators/default/async-obj-method.template
4 /*---
5 description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (object) (Async generator method)
6 esid: prod-AsyncGeneratorMethod
7 features: [Symbol.iterator, Symbol.asyncIterator, 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 ...
30
31 GetMethod ( V, P )
32
33 ...
34 2. Let func be ? GetV(V, P).
35 3. If func is either undefined or null, return undefined.
36 4. If IsCallable(func) is false, throw a TypeError exception.
37 ...
38
39 ---*/
40 var obj = {
41 get [Symbol.iterator]() {
42 throw new Test262Error('it should not get Symbol.iterator');
43 },
44 [Symbol.asyncIterator]: {}
45 };
46
47
48 var callCount = 0;
49
50 var gen = {
51 async *method() {
52 callCount += 1;
53 yield* obj;
54 throw new Test262Error('abrupt completion closes iter');
55
56 }
57 }.method;
58
59 var iter = gen();
60
61 iter.next().then(() => {
62 throw new Test262Error('Promise incorrectly fulfilled.');
63 }, v => {
64 assert.sameValue(v.constructor, TypeError, "TypeError");
65
66 iter.next().then(({ done, value }) => {
67 assert.sameValue(done, true, 'the iterator is completed');
68 assert.sameValue(value, undefined, 'value is undefined');
69 }).then($DONE, $DONE);
70 }).catch($DONE);
71
72 assert.sameValue(callCount, 1);