| 1 |
// |reftest| error:SyntaxError |
| 2 |
'use strict'; |
| 3 |
// This file was procedurally generated from the following sources: |
| 4 |
// - src/async-generators/yield-identifier-spread-strict.case |
| 5 |
// - src/async-generators/default/async-class-expr-private-method.template |
| 6 |
/*--- |
| 7 |
description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Async generator method as a ClassExpression element) |
| 8 |
esid: prod-AsyncGeneratorPrivateMethod |
| 9 |
features: [object-spread, async-iteration, class-methods-private] |
| 10 |
flags: [generated, onlyStrict] |
| 11 |
negative: |
| 12 |
phase: parse |
| 13 |
type: SyntaxError |
| 14 |
info: | |
| 15 |
ClassElement : |
| 16 |
PrivateMethodDefinition |
| 17 |
|
| 18 |
MethodDefinition : |
| 19 |
AsyncGeneratorMethod |
| 20 |
|
| 21 |
Async Generator Function Definitions |
| 22 |
|
| 23 |
AsyncGeneratorMethod : |
| 24 |
async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } |
| 25 |
|
| 26 |
|
| 27 |
Spread Properties |
| 28 |
|
| 29 |
PropertyDefinition[Yield]: |
| 30 |
(...) |
| 31 |
...AssignmentExpression[In, ?Yield] |
| 32 |
|
| 33 |
---*/ |
| 34 |
$DONOTEVALUATE(); |
| 35 |
|
| 36 |
|
| 37 |
var callCount = 0; |
| 38 |
|
| 39 |
var C = class { |
| 40 |
async *#gen() { |
| 41 |
callCount += 1; |
| 42 |
return { |
| 43 |
...(function() { |
| 44 |
var yield; |
| 45 |
throw new Test262Error(); |
| 46 |
}()), |
| 47 |
} |
| 48 |
} |
| 49 |
get gen() { return this.#gen; } |
| 50 |
} |
| 51 |
|
| 52 |
const c = new C(); |
| 53 |
|
| 54 |
// Test the private fields do not appear as properties before set to value |
| 55 |
assert( |
| 56 |
!Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), |
| 57 |
"#gen does not appear as an own property on C prototype" |
| 58 |
); |
| 59 |
assert( |
| 60 |
!Object.prototype.hasOwnProperty.call(C, "#gen"), |
| 61 |
"#gen does not appear as an own property on C constructor" |
| 62 |
); |
| 63 |
assert( |
| 64 |
!Object.prototype.hasOwnProperty.call(c, "#gen"), |
| 65 |
"#gen does not appear as an own property on C instance" |
| 66 |
); |
| 67 |
|
| 68 |
var iter = c.gen(); |
| 69 |
|
| 70 |
|
| 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 |
); |
| 83 |
assert( |
| 84 |
!Object.prototype.hasOwnProperty.call(c, "#gen"), |
| 85 |
"#gen does not appear as an own property on C instance" |
| 86 |
); |