| 1 |
// |reftest| async |
| 2 |
// This file was procedurally generated from the following sources: |
| 3 |
// - src/async-generators/yield-spread-arr-single.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 |
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 |
Array Initializer |
| 24 |
|
| 25 |
SpreadElement[Yield, Await]: |
| 26 |
...AssignmentExpression[+In, ?Yield, ?Await] |
| 27 |
|
| 28 |
---*/ |
| 29 |
var arr = ['a', 'b', 'c']; |
| 30 |
|
| 31 |
|
| 32 |
var callCount = 0; |
| 33 |
|
| 34 |
var C = class { |
| 35 |
static async *#gen() { |
| 36 |
callCount += 1; |
| 37 |
yield [...yield]; |
| 38 |
} |
| 39 |
static get gen() { return this.#gen; } |
| 40 |
} |
| 41 |
|
| 42 |
// Test the private fields do not appear as properties before set to value |
| 43 |
assert( |
| 44 |
!Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), |
| 45 |
"#gen does not appear as an own property on C prototype" |
| 46 |
); |
| 47 |
assert( |
| 48 |
!Object.prototype.hasOwnProperty.call(C, "#gen"), |
| 49 |
"#gen does not appear as an own property on C constructor" |
| 50 |
); |
| 51 |
|
| 52 |
var iter = C.gen(); |
| 53 |
|
| 54 |
iter.next(false); |
| 55 |
var item = iter.next(arr); |
| 56 |
|
| 57 |
item.then(({ done, value }) => { |
| 58 |
assert.notSameValue(value, arr, 'value is a new array'); |
| 59 |
assert(Array.isArray(value), 'value is an Array exotic object'); |
| 60 |
assert.sameValue(value.length, 3) |
| 61 |
assert.sameValue(value[0], 'a'); |
| 62 |
assert.sameValue(value[1], 'b'); |
| 63 |
assert.sameValue(value[2], 'c'); |
| 64 |
assert.sameValue(done, false); |
| 65 |
}).then($DONE, $DONE); |
| 66 |
|
| 67 |
assert.sameValue(callCount, 1); |
| 68 |
|
| 69 |
// Test the private fields do not appear as properties after set to value |
| 70 |
assert( |
| 71 |
!Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), |
| 72 |
"#gen does not appear as an own property on C prototype" |
| 73 |
); |
| 74 |
assert( |
| 75 |
!Object.prototype.hasOwnProperty.call(C, "#gen"), |
| 76 |
"#gen does not appear as an own property on C constructor" |
| 77 |
); |