Debian Codegraph @

js/src/tests/test262/language/expressions/class/elements/same-line-method-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-same-line-method.template
4 /*---
5 description: Literal property names (field definitions followed by a method in the same line)
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 a; b = 42;
28 c = fn; m() { return 42; }
29
30 }
31
32 var c = new C();
33
34 assert.sameValue(c.m(), 42);
35 assert.sameValue(c.m, C.prototype.m);
36 assert(
37 !Object.prototype.hasOwnProperty.call(c, "m"),
38 "m doesn't appear as an own property on the C instance"
39 );
40
41 verifyProperty(C.prototype, "m", {
42 enumerable: false,
43 configurable: true,
44 writable: true,
45 });
46
47 assert(
48 !Object.prototype.hasOwnProperty.call(C.prototype, "a"),
49 "a doesn't appear as an own property on C prototype"
50 );
51 assert(
52 !Object.prototype.hasOwnProperty.call(C, "a"),
53 "a doesn't appear as an own property on C constructor"
54 );
55
56 verifyProperty(c, "a", {
57 value: undefined,
58 enumerable: true,
59 writable: true,
60 configurable: true
61 });
62
63 assert(
64 !Object.prototype.hasOwnProperty.call(C.prototype, "b"),
65 "b doesn't appear as an own property on C prototype"
66 );
67 assert(
68 !Object.prototype.hasOwnProperty.call(C, "b"),
69 "b doesn't appear as an own property on C constructor"
70 );
71
72 verifyProperty(c, "b", {
73 value: 42,
74 enumerable: true,
75 writable: true,
76 configurable: true
77 });
78
79 assert(
80 !Object.prototype.hasOwnProperty.call(C.prototype, "c"),
81 "c doesn't appear as an own property on C prototype"
82 );
83 assert(
84 !Object.prototype.hasOwnProperty.call(C, "c"),
85 "c doesn't appear as an own property on C constructor"
86 );
87
88 verifyProperty(c, "c", {
89 value: fn,
90 enumerable: true,
91 writable: true,
92 configurable: true
93 });
94
95
96 reportCompare(0, 0);