Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/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-expr-static.template
4 /*---
5 description: Abrupt completion when coercing to property key value (Class expression, static method)
6 esid: sec-runtime-semantics-classdefinitionevaluation
7 es6id: 14.5.14
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 12.2.6.7 Runtime Semantics: Evaluation
19
20 [...]
21
22 ComputedPropertyName : [ AssignmentExpression ]
23
24 1. Let exprValue be the result of evaluating AssignmentExpression.
25 2. Let propName be ? GetValue(exprValue).
26 3. Return ? ToPropertyKey(propName).
27
28 7.1.14 ToPropertyKey
29
30 1. Let key be ? ToPrimitive(argument, hint String).
31
32 7.1.1 ToPrimitive
33
34 [...]
35 7. Return ? OrdinaryToPrimitive(input, hint).
36
37 7.1.1.1 OrdinaryToPrimitive
38
39 5. For each name in methodNames in List order, do
40 [...]
41 6. Throw a TypeError exception.
42 ---*/
43 var badKey = Object.create(null);
44
45
46 assert.throws(TypeError, function() {
47 0, class {
48 static get [badKey]() {}
49 };
50 }, '`get` accessor');
51
52 assert.throws(TypeError, function() {
53 0, class {
54 static set [badKey](_) {}
55 };
56 }, '`set` accessor');