Debian Codegraph @

js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-ctor-meth-valid.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/class-elements/grammar-static-ctor-meth-valid.case
3 // - src/class-elements/syntax/valid/cls-decl-elements-valid-syntax.template
4 /*---
5 description: Static Methods can be named constructor (class declaration)
6 esid: prod-ClassElement
7 features: [class]
8 flags: [generated]
9 info: |
10 Class Definitions / Static Semantics: Early Errors
11
12 ClassElement : MethodDefinition
13 It is a Syntax Error if PropName of MethodDefinition is not "constructor" and HasDirectSuper of MethodDefinition is true.
14 It is a Syntax Error if PropName of MethodDefinition is "constructor" and SpecialMethod of MethodDefinition is true.
15 ClassElement : static MethodDefinition
16 It is a Syntax Error if HasDirectSuper of MethodDefinition is true.
17 It is a Syntax Error if PropName of MethodDefinition is "prototype".
18
19 ---*/
20
21
22 class C {
23 static constructor() {}
24 constructor() {} // stacks with a valid constructor
25 }
26
27 assert(C.hasOwnProperty('constructor'));
28 assert(C.prototype.hasOwnProperty('constructor'));
29 assert.notSameValue(C.prototype.constructor, C.constructor);
30
31 reportCompare(0, 0);