Debian Codegraph @

js/src/tests/test262/language/statements/class/elements/private-method-comparison.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/class-elements/private-method-comparison.case
3 // - src/class-elements/default/cls-decl.template
4 /*---
5 description: PrivateFieldGet of a private method returns the same function object to every instance of the same class (field definitions in a class declaration)
6 esid: prod-FieldDefinition
7 features: [class, class-methods-private]
8 flags: [generated]
9 info: |
10 PrivateFieldGet (P, O)
11 1. Assert: P is a Private Name.
12 2. If O is not an object, throw a TypeError exception.
13 3. If P.[[Kind]] is "field",
14 a. Let entry be PrivateFieldFind(P, O).
15 b. If entry is empty, throw a TypeError exception.
16 c. Return entry.[[PrivateFieldValue]].
17 4. Perform ? PrivateBrandCheck(O, P).
18 5. If P.[[Kind]] is "method",
19 a. Return P.[[Value]].
20 6. Else,
21 a. Assert: P.[[Kind]] is "accessor".
22 b. If P does not have a [[Get]] field, throw a TypeError exception.
23 c. Let getter be P.[[Get]].
24 d. Return ? Call(getter, O).
25
26 PrivateBrandCheck(O, P)
27 1. If O.[[PrivateBrands]] does not contain an entry e such that SameValue(e, P.[[Brand]]) is true,
28 a. Throw a TypeError exception.
29
30 ---*/
31
32
33 class C {
34 #m() { return 'test262'; }
35
36 getPrivateMethod() {
37 return this.#m;
38 }
39
40 }
41
42 let c1 = new C();
43 let c2 = new C();
44
45 assert.sameValue(c1.getPrivateMethod(), c2.getPrivateMethod());
46
47 reportCompare(0, 0);