Debian Codegraph @

js/src/tests/test262/language/expressions/class/elements/multiple-definitions-literal-names.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/class-elements/literal-names.case
3 // - src/class-elements/productions/cls-expr-multiple-definitions.template
4 /*---
5 description: Literal property names (multiple fields definitions)
6 esid: prod-FieldDefinition
7 features: [class-fields-public, 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 const fn = function() {}
23
24
25
26 var C = class {
27 foo = "foobar";
28 m() { return 42 }
29 a; b = 42;
30 c = fn
31 m2() { return 39 }
32 bar = "barbaz";
33
34 }
35
36 var c = new C();
37
38 assert.sameValue(c.m(), 42);
39 assert(
40 !Object.prototype.hasOwnProperty.call(c, "m"),
41 "m doesn't appear as an own property on the C instance"
42 );
43 assert.sameValue(c.m, C.prototype.m);
44
45 verifyProperty(C.prototype, "m", {
46 enumerable: false,
47 configurable: true,
48 writable: true,
49 });
50
51 assert.sameValue(c.m2(), 39);
52 assert(
53 !Object.prototype.hasOwnProperty.call(c, "m2"),
54 "m2 doesn't appear as an own property on the C instance"
55 );
56 assert.sameValue(c.m2, C.prototype.m2);
57
58 verifyProperty(C.prototype, "m2", {
59 enumerable: false,
60 configurable: true,
61 writable: true,
62 });
63
64 assert.sameValue(c.foo, "foobar");
65 assert(
66 !Object.prototype.hasOwnProperty.call(C, "foo"),
67 "foo doesn't appear as an own property on the C constructor"
68 );
69 assert(
70 !Object.prototype.hasOwnProperty.call(C.prototype, "foo"),
71 "foo doesn't appear as an own property on the C prototype"
72 );
73
74 verifyProperty(c, "foo", {
75 value: "foobar",
76 enumerable: true,
77 configurable: true,
78 writable: true,
79 });
80
81 assert.sameValue(c.bar, "barbaz");
82 assert(
83 !Object.prototype.hasOwnProperty.call(C, "bar"),
84 "bar doesn't appear as an own property on the C constructor"
85 );
86 assert(
87 !Object.prototype.hasOwnProperty.call(C.prototype, "bar"),
88 "bar doesn't appear as an own property on the C prototype"
89 );
90
91 verifyProperty(c, "bar", {
92 value: "barbaz",
93 enumerable: true,
94 configurable: true,
95 writable: true,
96 });
97
98 assert(
99 !Object.prototype.hasOwnProperty.call(C.prototype, "a"),
100 "a doesn't appear as an own property on C prototype"
101 );
102 assert(
103 !Object.prototype.hasOwnProperty.call(C, "a"),
104 "a doesn't appear as an own property on C constructor"
105 );
106
107 verifyProperty(c, "a", {
108 value: undefined,
109 enumerable: true,
110 writable: true,
111 configurable: true
112 });
113
114 assert(
115 !Object.prototype.hasOwnProperty.call(C.prototype, "b"),
116 "b doesn't appear as an own property on C prototype"
117 );
118 assert(
119 !Object.prototype.hasOwnProperty.call(C, "b"),
120 "b doesn't appear as an own property on C constructor"
121 );
122
123 verifyProperty(c, "b", {
124 value: 42,
125 enumerable: true,
126 writable: true,
127 configurable: true
128 });
129
130 assert(
131 !Object.prototype.hasOwnProperty.call(C.prototype, "c"),
132 "c doesn't appear as an own property on C prototype"
133 );
134 assert(
135 !Object.prototype.hasOwnProperty.call(C, "c"),
136 "c doesn't appear as an own property on C constructor"
137 );
138
139 verifyProperty(c, "c", {
140 value: fn,
141 enumerable: true,
142 writable: true,
143 configurable: true
144 });
145
146
147 reportCompare(0, 0);