Debian Codegraph @

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

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