summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/statements/class/elements/static-private-fields-proxy-default-handler-throws.js
blob: 8752878264832edf99d49bc0590fd2b72cdda7a4 (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
// Copyright (C) 2018 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-privatefieldget
description: Static private fields not accessible via default Proxy handler
info: |
  1. Assert: P is a Private Name value.
  2. If O is not an object, throw a TypeError exception.
  3. Let entry be PrivateFieldFind(P, O).
  4. If entry is empty, throw a TypeError exception.

features: [class, class-static-fields-private]
---*/

class C {
  static #x = 1;
  static x() {
    return this.#x;
  }
}

var P = new Proxy(C, {});

assert.sameValue(C.x(), 1);
assert.throws(TypeError, function() {
  P.x();
});

reportCompare(0, 0);