Debian Codegraph @

js/src/tests/test262/language/statements/class/elements/multiple-definitions-private-method-usage.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/class-elements/private-method-usage.case
3 // - src/class-elements/productions/cls-decl-multiple-definitions.template
4 /*---
5 description: PrivateName CallExpression usage (private method) (multiple fields definitions)
6 esid: prod-FieldDefinition
7 features: [class-methods-private, class, class-fields-public]
8 flags: [generated]
9 includes: [propertyHelper.js]
10 info: |
11 Updated Productions
12
13 CallExpression[Yield, Await]:
14 CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await]
15 SuperCall[?Yield, ?Await]
16 CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await]
17 CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]]
18 CallExpression[?Yield, ?Await].IdentifierName
19 CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await]
20 CallExpression[?Yield, ?Await].PrivateName
21
22 ---*/
23
24
25 class C {
26 foo = "foobar";
27 m() { return 42 }
28 #m() { return 'test262'; }
29 m2() { return 39 }
30 bar = "barbaz";
31 method() {
32 return this.#m();
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.sameValue(c.method(), 'test262');
99
100 reportCompare(0, 0);