Debian Codegraph @

js/src/tests/test262/language/expressions/class/elements/async-gen-private-method-static/yield-spread-arr-multiple.js

raw
1 // |reftest| async
2 // This file was procedurally generated from the following sources:
3 // - src/async-generators/yield-spread-arr-multiple.case
4 // - src/async-generators/default/async-class-expr-static-private-method.template
5 /*---
6 description: Use yield value in a array spread position (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 includes: [compareArray.js]
11 info: |
12 ClassElement :
13 static PrivateMethodDefinition
14
15 MethodDefinition :
16 AsyncGeneratorMethod
17
18 Async Generator Function Definitions
19
20 AsyncGeneratorMethod :
21 async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody }
22
23
24 Array Initializer
25
26 SpreadElement[Yield, Await]:
27 ...AssignmentExpression[+In, ?Yield, ?Await]
28
29 ---*/
30 var arr = ['a', 'b', 'c'];
31 var item;
32
33
34 var callCount = 0;
35
36 var C = class {
37 static async *#gen() {
38 callCount += 1;
39 yield [...yield yield];
40 }
41 static get gen() { return this.#gen; }
42 }
43
44 // Test the private fields do not appear as properties before set to value
45 assert(
46 !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"),
47 "#gen does not appear as an own property on C prototype"
48 );
49 assert(
50 !Object.prototype.hasOwnProperty.call(C, "#gen"),
51 "#gen does not appear as an own property on C constructor"
52 );
53
54 var iter = C.gen();
55
56 iter.next(false);
57 item = iter.next(['a', 'b', 'c']);
58
59 item.then(({ done, value }) => {
60 item = iter.next(value);
61
62 item.then(({ done, value }) => {
63 assert.compareArray(value, arr);
64 assert.sameValue(done, false);
65 }).then($DONE, $DONE);
66 }).catch($DONE);
67
68 assert.sameValue(callCount, 1);
69
70 // Test the private fields do not appear as properties after 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 );