Debian Codegraph @

js/src/tests/test262/language/statements/class/elements/async-gen-private-method/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-decl-private-method.template
5 /*---
6 description: Use yield value in a array spread position (Async Generator method as a ClassDeclaration element)
7 esid: prod-AsyncGeneratorPrivateMethod
8 features: [async-iteration, class-methods-private]
9 flags: [generated, async]
10 includes: [compareArray.js]
11 info: |
12 ClassElement :
13 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 class C {
37 async *#gen() {
38 callCount += 1;
39 yield [...yield yield];
40 }
41 get gen() { return this.#gen; }
42 }
43
44 const c = new C();
45
46 // Test the private fields do not appear as properties before set to value
47 assert(
48 !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"),
49 "#gen does not appear as an own property on C prototype"
50 );
51 assert(
52 !Object.prototype.hasOwnProperty.call(C, "#gen"),
53 "#gen does not appear as an own property on C constructor"
54 );
55 assert(
56 !Object.prototype.hasOwnProperty.call(c, "#gen"),
57 "#gen does not appear as an own property on C instance"
58 );
59
60 var iter = c.gen();
61
62 iter.next(false);
63 item = iter.next(['a', 'b', 'c']);
64
65 item.then(({ done, value }) => {
66 item = iter.next(value);
67
68 item.then(({ done, value }) => {
69 assert.compareArray(value, arr);
70 assert.sameValue(done, false);
71 }).then($DONE, $DONE);
72 }).catch($DONE);
73
74 assert.sameValue(callCount, 1);
75
76 // Test the private fields do not appear as properties after set to value
77 assert(
78 !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"),
79 "#gen does not appear as an own property on C prototype"
80 );
81 assert(
82 !Object.prototype.hasOwnProperty.call(C, "#gen"),
83 "#gen does not appear as an own property on C constructor"
84 );
85 assert(
86 !Object.prototype.hasOwnProperty.call(c, "#gen"),
87 "#gen does not appear as an own property on C instance"
88 );