Debian Codegraph @

js/src/tests/test262/language/statements/class/elements/private-method-double-initialisation-get-and-set.js

raw
1 // Copyright (C) 2021 André Bargull. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 description: >
6 Throws TypeError when attempting to install private methods multiple times.
7 esid: sec-privatemethodoraccessoradd
8 info: |
9 7.3.28 PrivateMethodOrAccessorAdd ( method, O )
10 1. Assert: method.[[Kind]] is either method or accessor.
11 2. Let entry be ! PrivateElementFind(method.[[Key]], O).
12 3. If entry is not empty, throw a TypeError exception.
13 ...
14
15 features: [class, class-methods-private]
16 ---*/
17
18 class Base {
19 constructor(o) {
20 return o;
21 }
22 }
23
24 class C extends Base {
25 get #p() {}
26 set #p(x) {}
27 }
28
29 var obj = {};
30
31 new C(obj);
32
33 assert.throws(TypeError, function() {
34 new C(obj);
35 });
36
37 reportCompare(0, 0);