| 1 |
// This file was procedurally generated from the following sources: |
| 2 |
// - src/class-fields/propname-constructor.case |
| 3 |
// - src/class-fields/propname-error/cls-expr-variable-name.template |
| 4 |
/*--- |
| 5 |
description: class fields forbid PropName 'constructor' (no early error -- PropName of ComputedPropertyName not forbidden value) |
| 6 |
esid: sec-class-definitions-static-semantics-early-errors |
| 7 |
features: [class, class-fields-public] |
| 8 |
flags: [generated] |
| 9 |
info: | |
| 10 |
Static Semantics: PropName |
| 11 |
... |
| 12 |
ComputedPropertyName : [ AssignmentExpression ] |
| 13 |
Return empty. |
| 14 |
|
| 15 |
|
| 16 |
// This test file tests the following early error: |
| 17 |
Static Semantics: Early Errors |
| 18 |
|
| 19 |
ClassElement : FieldDefinition; |
| 20 |
It is a Syntax Error if PropName of FieldDefinition is "constructor". |
| 21 |
|
| 22 |
---*/ |
| 23 |
|
| 24 |
|
| 25 |
var constructor = 'foo'; |
| 26 |
var C = class { |
| 27 |
[constructor]; |
| 28 |
}; |
| 29 |
|
| 30 |
var c = new C(); |
| 31 |
assert.sameValue(c.hasOwnProperty("foo"), true); |
| 32 |
|
| 33 |
assert.sameValue(C.hasOwnProperty("foo"), false); |