Debian Codegraph @

js/src/tests/test262/language/statements/class/elements/private-static-setter-abrupt-completition.js

raw
1 // Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 description: PrivateFieldSet should return an abrupt completion
6 esid: sec-privatefieldset
7 info: |
8 PrivateFieldSet (P, O, value)
9 1. Assert: P is a Private Name.
10 2. If O is not an object, throw a TypeError exception.
11 3. If P.[[Kind]] is "field",
12 a. Let entry be PrivateFieldFind(P, O).
13 b. If entry is empty, throw a TypeError exception.
14 c. Set entry.[[PrivateFieldValue]] to value.
15 d. Return.
16 4. If P.[[Kind]] is "method", throw a TypeError exception.
17 5. Else,
18 a. Assert: P.[[Kind]] is "accessor".
19 b. If O.[[PrivateFieldBrands]] does not contain P.[[Brand]], throw a TypeError exception.
20 c. If P does not have a [[Set]] field, throw a TypeError exception.
21 d. Let setter be P.[[Set]].
22 e. Perform ? Call(setter, O, value).
23 f. Return.
24 features: [class-methods-private, class]
25 ---*/
26
27 class C {
28 set #m(_) {
29 throw new Test262Error();
30 }
31
32 access() {
33 this.#m = 'Test262';
34 }
35 }
36
37 let c = new C();
38 assert.throws(Test262Error, function() {
39 c.access();
40 }, 'private setter should have abrupt completion');
41
42 reportCompare(0, 0);