Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/class/async-gen-method-yield-star-next-non-object-ignores-then.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/async-generators/yield-star-next-non-object-ignores-then.case
3 // - src/async-generators/default/async-class-expr-method.template
4 /*---
5 description: If next() value is not-object, do not access respective then property (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 6. Repeat
25 a. If received.[[Type]] is normal, then
26 ii. Let innerResult be ? Invoke(iterator, "next",
27 « received.[[Value]] »).
28 iii. If generatorKind is async, then set innerResult to
29 ? Await(innerResult).
30 iv. If Type(innerResult) is not Object, throw a TypeError exception.
31 ...
32
33 Await
34
35 ...
36 2. Let promiseCapability be ! NewPromiseCapability(%Promise%).
37 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »).
38 ...
39
40 Promise Resolve Functions
41
42 ...
43 7. If Type(resolution) is not Object, then
44 a. Return FulfillPromise(promise, resolution).
45 8. Let then be Get(resolution, "then").
46 ...
47
48 ---*/
49 Number.prototype.then = function() {
50 throw new Test262Error('Number#then should not be used');
51 };
52 var obj = {
53 get [Symbol.iterator]() {
54 throw new Test262Error('it should not get Symbol.iterator');
55 },
56 [Symbol.asyncIterator]() {
57 return {
58 next() {
59 return 42;
60 }
61 };
62 }
63 };
64
65
66
67 var callCount = 0;
68
69 var C = class { async *gen() {
70 callCount += 1;
71 yield* obj;
72 throw new Test262Error('abrupt completion closes iter');
73
74 }}
75
76 var gen = C.prototype.gen;
77
78 var iter = gen();
79
80 iter.next().then(() => {
81 throw new Test262Error('Promise incorrectly fulfilled.');
82 }, v => {
83 assert.sameValue(v.constructor, TypeError, 'TypeError');
84
85 iter.next().then(({ done, value }) => {
86 assert.sameValue(done, true, 'the iterator is completed');
87 assert.sameValue(value, undefined, 'value is undefined');
88 }).then($DONE, $DONE);
89 }).catch($DONE);
90
91 assert.sameValue(callCount, 1);