Debian Codegraph @

js/src/tests/test262/language/expressions/in/private-field-presence-method-shadowed.js

raw
1 // Copyright 2021 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 description: Value when private name describes a method
6 info: |
7 7. Let privateName be ? GetValue(privateNameBinding).
8 8. Assert: privateName is a Private Name.
9 [...]
10 10. Else,
11 a. Assert: privateName.[[Kind]] is "method" or "accessor".
12 b. If PrivateBrandCheck(rval, privateName) is not an abrupt completion,
13 then return true.
14 11. Return false.
15 esid: sec-relational-operators-runtime-semantics-evaluation
16 features: [class-methods-private, class-fields-private-in]
17 ---*/
18
19 let Child;
20 let parentCount = 0;
21 let childCount = 0;
22
23 class Parent {
24 #method() {
25 parentCount += 1;
26 }
27
28 static init() {
29 Child = class {
30 #method() {
31 childCount += 1;
32 }
33
34 static isNameIn(value) {
35 return #method in value;
36 }
37 };
38 }
39 }
40
41 Parent.init();
42
43 assert.sameValue(Child.isNameIn(new Parent()), false);
44 assert.sameValue(parentCount, 0, 'parent method not invoked');
45 assert.sameValue(Child.isNameIn(new Child()), true);
46 assert.sameValue(childCount, 0, 'child method not invoked');
47
48 reportCompare(0, 0);