Debian Codegraph @

js/src/tests/test262/language/expressions/class/elements/async-gen-private-method-static/yield-star-expr-abrupt.js

raw
1 // |reftest| async
2 // This file was procedurally generated from the following sources:
3 // - src/async-generators/yield-star-expr-abrupt.case
4 // - src/async-generators/default/async-class-expr-static-private-method.template
5 /*---
6 description: Abrupt completion while getting yield* operand (Static async generator method as a ClassExpression element)
7 esid: prod-AsyncGeneratorPrivateMethod
8 features: [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 1. Let exprRef be the result of evaluating AssignmentExpression.
26 2. Let value be ? GetValue(exprRef).
27 ...
28
29 ---*/
30 var obj = {};
31 var abrupt = function() {
32 throw obj;
33 };
34
35
36
37 var callCount = 0;
38
39 var C = class {
40 static async *#gen() {
41 callCount += 1;
42 yield* abrupt();
43 throw new Test262Error('abrupt completion closes iter');
44
45 }
46 static get gen() { return this.#gen; }
47 }
48
49 // Test the private fields do not appear as properties before set to value
50 assert(
51 !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"),
52 "#gen does not appear as an own property on C prototype"
53 );
54 assert(
55 !Object.prototype.hasOwnProperty.call(C, "#gen"),
56 "#gen does not appear as an own property on C constructor"
57 );
58
59 var iter = C.gen();
60
61 iter.next().then(() => {
62 throw new Test262Error('Promise incorrectly fulfilled.');
63 }, v => {
64 assert.sameValue(v, obj, "reject reason");
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);
73
74 // Test the private fields do not appear as properties after set to value
75 assert(
76 !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"),
77 "#gen does not appear as an own property on C prototype"
78 );
79 assert(
80 !Object.prototype.hasOwnProperty.call(C, "#gen"),
81 "#gen does not appear as an own property on C constructor"
82 );