Debian Codegraph @

js/src/tests/test262/language/statements/class/accessor-name-static/computed-err-to-prop-key.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/accessor-names/computed-err-to-prop-key.case
3 // - src/accessor-names/error/cls-decl-static.template
4 /*---
5 description: Abrupt completion when coercing to property key value (Class declaration, static method)
6 esid: sec-runtime-semantics-classdefinitionevaluation
7 features: [class]
8 flags: [generated]
9 info: |
10 [...]
11 21. For each ClassElement m in order from methods
12 a. If IsStatic of m is false, then
13 [...]
14 b. Else,
15 a. Let status be the result of performing PropertyDefinitionEvaluation
16 for m with arguments F and false.
17
18
19 12.2.6.7 Runtime Semantics: Evaluation
20
21 [...]
22
23 ComputedPropertyName : [ AssignmentExpression ]
24
25 1. Let exprValue be the result of evaluating AssignmentExpression.
26 2. Let propName be ? GetValue(exprValue).
27 3. Return ? ToPropertyKey(propName).
28
29 7.1.14 ToPropertyKey
30
31 1. Let key be ? ToPrimitive(argument, hint String).
32
33 7.1.1 ToPrimitive
34
35 [...]
36 7. Return ? OrdinaryToPrimitive(input, hint).
37
38 7.1.1.1 OrdinaryToPrimitive
39
40 5. For each name in methodNames in List order, do
41 [...]
42 6. Throw a TypeError exception.
43 ---*/
44 var badKey = Object.create(null);
45
46
47 assert.throws(TypeError, function() {
48 class C {
49 static get [badKey]() {}
50 }
51 }, '`get` accessor');
52
53 assert.throws(TypeError, function() {
54 class C {
55 static set [badKey](_) {}
56 }
57 }, '`set` accessor');
58
59 reportCompare(0, 0);