Debian Codegraph @

js/src/tests/test262/language/expressions/class/elements/async-gen-private-method/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-private-method.template
5 /*---
6 description: Abrupt completion while getting yield* operand (Async generator method as a ClassExpression element)
7 esid: prod-AsyncGeneratorPrivateMethod
8 features: [async-iteration, class-methods-private]
9 flags: [generated, async]
10 info: |
11 ClassElement :
12 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 async *#gen() {
41 callCount += 1;
42 yield* abrupt();
43 throw new Test262Error('abrupt completion closes iter');
44
45 }
46 get gen() { return this.#gen; }
47 }
48
49 const c = new C();
50
51 // Test the private fields do not appear as properties before set to value
52 assert(
53 !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"),
54 "#gen does not appear as an own property on C prototype"
55 );
56 assert(
57 !Object.prototype.hasOwnProperty.call(C, "#gen"),
58 "#gen does not appear as an own property on C constructor"
59 );
60 assert(
61 !Object.prototype.hasOwnProperty.call(c, "#gen"),
62 "#gen does not appear as an own property on C instance"
63 );
64
65 var iter = c.gen();
66
67 iter.next().then(() => {
68 throw new Test262Error('Promise incorrectly fulfilled.');
69 }, v => {
70 assert.sameValue(v, obj, "reject reason");
71
72 iter.next().then(({ done, value }) => {
73 assert.sameValue(done, true, 'the iterator is completed');
74 assert.sameValue(value, undefined, 'value is undefined');
75 }).then($DONE, $DONE);
76 }).catch($DONE);
77
78 assert.sameValue(callCount, 1);
79
80 // Test the private fields do not appear as properties after set to value
81 assert(
82 !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"),
83 "#gen does not appear as an own property on C prototype"
84 );
85 assert(
86 !Object.prototype.hasOwnProperty.call(C, "#gen"),
87 "#gen does not appear as an own property on C constructor"
88 );
89 assert(
90 !Object.prototype.hasOwnProperty.call(c, "#gen"),
91 "#gen does not appear as an own property on C instance"
92 );