Debian Codegraph @

js/src/tests/test262/language/statements/class/elements/fields-hash-constructor-is-a-valid-name.js

raw
1 // Copyright (C) 2018 Leo Balter. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 description: "#constructor is a valid property name for a public field"
5 esid: sec-class-definitions-static-semantics-early-errors
6 features: [class, class-fields-public]
7 info: |
8 ClassElementName : PrivateName;
9
10 It is a Syntax Error if StringValue of PrivateName is "#constructor".
11 includes: [propertyHelper.js]
12 ---*/
13
14 class C1 {
15 ["#constructor"];
16 }
17
18 var c1 = new C1();
19
20 assert.sameValue(Object.prototype.hasOwnProperty.call(C1, '#constructor'), false);
21 verifyProperty(c1, '#constructor', {
22 value: undefined,
23 configurable: true,
24 enumerable: true,
25 writable: true,
26 });
27
28 class C2 {
29 ["#constructor"] = 42;
30 }
31
32 var c2 = new C2();
33
34 assert.sameValue(Object.prototype.hasOwnProperty.call(C2, '#constructor'), false);
35 verifyProperty(c2, '#constructor', {
36 value: 42,
37 configurable: true,
38 enumerable: true,
39 writable: true,
40 });
41
42 reportCompare(0, 0);