summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/statements/class/elements/private-method-double-initialisation-get.js
blob: 76699517219a7825de2b98d79fb995f44f9c8065 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright (C) 2021 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: >
  Throws TypeError when attempting to install private methods multiple times.
esid: sec-privatemethodoraccessoradd
info: |
  7.3.28 PrivateMethodOrAccessorAdd ( method, O )
    1. Assert: method.[[Kind]] is either method or accessor.
    2. Let entry be ! PrivateElementFind(method.[[Key]], O).
    3. If entry is not empty, throw a TypeError exception.
    ...

features: [class, class-methods-private]
---*/

class Base {
  constructor(o) {
    return o;
  }
}

class C extends Base {
  get #p() {}
}

var obj = {};

new C(obj);

assert.throws(TypeError, function() {
  new C(obj);
});

reportCompare(0, 0);