test262/test/language/expressions/class/static-private-fields-proxy...

29 lines
673 B
JavaScript
Raw Normal View History

2018-08-01 20:20:57 +02:00
// 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]
---*/
var C = class {
static #x = 1;
static x() {
return this.#x;
}
}
var P = new Proxy(C, {});
2018-08-10 17:52:50 +02:00
assert.sameValue(C.x(), 1);
2018-08-01 20:20:57 +02:00
assert.throws(TypeError, function() {
2018-08-10 17:52:50 +02:00
P.x();
2018-08-01 20:20:57 +02:00
});