Debian Codegraph @

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

raw
1 // |reftest| async
2 // This file was procedurally generated from the following sources:
3 // - src/async-generators/yield-star-next-get-abrupt.case
4 // - src/async-generators/default/async-class-decl-static-private-method.template
5 /*---
6 description: Abrupt completion while getting next (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 ...
30
31 ---*/
32 var reason = {};
33 var obj = {
34 get [Symbol.iterator]() {
35 throw new Test262Error('it should not get Symbol.iterator');
36 },
37 [Symbol.asyncIterator]() {
38 return {
39 get next() {
40 throw reason;
41 }
42 };
43 }
44 };
45
46
47
48 var callCount = 0;
49
50 class C {
51 static async *#gen() {
52 callCount += 1;
53 yield* obj;
54 throw new Test262Error('abrupt completion closes iter');
55
56 }
57 static get gen() { return this.#gen; }
58 }
59
60 // Test the private fields do not appear as properties before set to value
61 assert(
62 !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"),
63 "#gen does not appear as an own property on C prototype"
64 );
65 assert(
66 !Object.prototype.hasOwnProperty.call(C, "#gen"),
67 "#gen does not appear as an own property on C constructor"
68 );
69
70 var iter = C.gen();
71
72 iter.next().then(() => {
73 throw new Test262Error('Promise incorrectly fulfilled.');
74 }, v => {
75 assert.sameValue(v, reason, "reject reason");
76
77 iter.next().then(({ done, value }) => {
78 assert.sameValue(done, true, 'the iterator is completed');
79 assert.sameValue(value, undefined, 'value is undefined');
80 }).then($DONE, $DONE);
81 }).catch($DONE);
82
83 assert.sameValue(callCount, 1);
84
85 // Test the private fields do not appear as properties after set to value
86 assert(
87 !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"),
88 "#gen does not appear as an own property on C prototype"
89 );
90 assert(
91 !Object.prototype.hasOwnProperty.call(C, "#gen"),
92 "#gen does not appear as an own property on C constructor"
93 );