Debian Codegraph @

js/src/tests/test262/language/statements/class/elements/same-line-method-computed-names.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/class-elements/computed-names.case
3 // - src/class-elements/productions/cls-decl-same-line-method.template
4 /*---
5 description: Computed property names (field definitions followed by a method in the same line)
6 esid: prod-FieldDefinition
7 features: [class-fields-public, computed-property-names, class]
8 flags: [generated]
9 includes: [propertyHelper.js]
10 info: |
11 ClassElement:
12 ...
13 FieldDefinition ;
14
15 FieldDefinition:
16 ClassElementName Initializer_opt
17
18 ClassElementName:
19 PropertyName
20
21 ---*/
22 var x = "b";
23
24
25
26 class C {
27 [x] = 42; [10] = "meep"; ["not initialized"]; m() { return 42; }
28
29 }
30
31 var c = new C();
32
33 assert.sameValue(c.m(), 42);
34 assert.sameValue(c.m, C.prototype.m);
35 assert(
36 !Object.prototype.hasOwnProperty.call(c, "m"),
37 "m doesn't appear as an own property on the C instance"
38 );
39
40 verifyProperty(C.prototype, "m", {
41 enumerable: false,
42 configurable: true,
43 writable: true,
44 });
45
46 assert(
47 !Object.prototype.hasOwnProperty.call(C.prototype, "b"),
48 "b doesn't appear as an own property on C prototype"
49 );
50 assert(
51 !Object.prototype.hasOwnProperty.call(C, "b"),
52 "b doesn't appear as an own property on C constructor"
53 );
54
55 verifyProperty(c, "b", {
56 value: 42,
57 enumerable: true,
58 writable: true,
59 configurable: true
60 });
61
62 assert(
63 !Object.prototype.hasOwnProperty.call(C.prototype, "x"),
64 "x doesn't appear as an own property on C prototype"
65 );
66 assert(
67 !Object.prototype.hasOwnProperty.call(C, "x"),
68 "x doesn't appear as an own property on C constructor"
69 );
70 assert(
71 !Object.prototype.hasOwnProperty.call(c, "x"),
72 "x doesn't appear as an own property on C instance"
73 );
74
75 assert(
76 !Object.prototype.hasOwnProperty.call(C.prototype, "10"),
77 "10 doesn't appear as an own property on C prototype"
78 );
79 assert(
80 !Object.prototype.hasOwnProperty.call(C, "10"),
81 "10 doesn't appear as an own property on C constructor"
82 );
83
84 verifyProperty(c, "10", {
85 value: "meep",
86 enumerable: true,
87 writable: true,
88 configurable: true
89 });
90
91 assert(
92 !Object.prototype.hasOwnProperty.call(C.prototype, "not initialized"),
93 "'not initialized' doesn't appear as an own property on C prototype"
94 );
95 assert(
96 !Object.prototype.hasOwnProperty.call(C, "not initialized"),
97 "'not initialized' doesn't appear as an own property on C constructor"
98 );
99
100 verifyProperty(c, "not initialized", {
101 value: undefined,
102 enumerable: true,
103 writable: true,
104 configurable: true
105 });
106
107 reportCompare(0, 0);