Debian Codegraph @

js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-call-value-get-abrupt.js

raw
1 // |reftest| async
2 // This file was procedurally generated from the following sources:
3 // - src/async-generators/yield-star-next-call-value-get-abrupt.case
4 // - src/async-generators/default/async-class-decl-static-private-method.template
5 /*---
6 description: Abrupt completion while getting value (Static async generator method as a ClassDeclaration element)
7 esid: prod-AsyncGeneratorPrivateMethod
8 features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private]
9 flags: [generated, async]
10 info: |
11 ClassElement :
12 static PrivateMethodDefinition
13
14 MethodDefinition :
15 AsyncGeneratorMethod
16
17 Async Generator Function Definitions
18
19 AsyncGeneratorMethod :
20 async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody }
21
22
23 YieldExpression: yield * AssignmentExpression
24 ...
25 6. Repeat
26 a. If received.[[Type]] is normal, then
27 ii. Let innerResult be ? Invoke(iterator, "next",
28 « received.[[Value]] »).
29 iii. If generatorKind is async, then set innerResult to
30 ? Await(innerResult).
31 ...
32 vi. If done is true, then
33 1. Return ? IteratorValue(innerResult).
34 ...
35
36 ---*/
37 var reason = {};
38 var obj = {
39 get [Symbol.iterator]() {
40 throw new Test262Error('it should not get Symbol.iterator');
41 },
42 [Symbol.asyncIterator]() {
43 return {
44 next() {
45 return {
46 done: true,
47 get value() {
48 throw reason;
49 }
50 };
51 }
52 };
53 }
54 };
55
56
57
58 var callCount = 0;
59
60 class C {
61 static async *#gen() {
62 callCount += 1;
63 yield* obj;
64 throw new Test262Error('abrupt completion closes iter');
65
66 }
67 static get gen() { return this.#gen; }
68 }
69
70 // Test the private fields do not appear as properties before set to value
71 assert(
72 !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"),
73 "#gen does not appear as an own property on C prototype"
74 );
75 assert(
76 !Object.prototype.hasOwnProperty.call(C, "#gen"),
77 "#gen does not appear as an own property on C constructor"
78 );
79
80 var iter = C.gen();
81
82 iter.next().then(() => {
83 throw new Test262Error('Promise incorrectly fulfilled.');
84 }, v => {
85 assert.sameValue(v, reason, "reject reason");
86
87 iter.next().then(({ done, value }) => {
88 assert.sameValue(done, true, 'the iterator is completed');
89 assert.sameValue(value, undefined, 'value is undefined');
90 }).then($DONE, $DONE);
91 }).catch($DONE);
92
93 assert.sameValue(callCount, 1);
94
95 // Test the private fields do not appear as properties after set to value
96 assert(
97 !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"),
98 "#gen does not appear as an own property on C prototype"
99 );
100 assert(
101 !Object.prototype.hasOwnProperty.call(C, "#gen"),
102 "#gen does not appear as an own property on C constructor"
103 );