Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/object/accessor-name-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/obj.template
4 /*---
5 description: Abrupt completion when coercing to property key value (Object initializer)
6 esid: sec-object-initializer-runtime-semantics-evaluation
7 es6id: 12.2.6.8
8 flags: [generated]
9 info: |
10 ObjectLiteral :
11 { PropertyDefinitionList }
12 { PropertyDefinitionList , }
13
14 1. Let obj be ObjectCreate(%ObjectPrototype%).
15 2. Let status be the result of performing PropertyDefinitionEvaluation of
16 PropertyDefinitionList with arguments obj and true.
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 ({
48 get [badKey]() {}
49 });
50 }, '`get` accessor');
51
52 assert.throws(TypeError, function() {
53 ({
54 set [badKey](_) {}
55 });
56 }, '`set` accessor');