Debian Codegraph @

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