Debian Codegraph @

js/src/tests/test262/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 flags: [generated]
8 info: |
9 ObjectLiteral :
10 { PropertyDefinitionList }
11 { PropertyDefinitionList , }
12
13 1. Let obj be ObjectCreate(%ObjectPrototype%).
14 2. Let status be the result of performing PropertyDefinitionEvaluation of
15 PropertyDefinitionList with arguments obj and true.
16
17 12.2.6.7 Runtime Semantics: Evaluation
18
19 [...]
20
21 ComputedPropertyName : [ AssignmentExpression ]
22
23 1. Let exprValue be the result of evaluating AssignmentExpression.
24 2. Let propName be ? GetValue(exprValue).
25 3. Return ? ToPropertyKey(propName).
26
27 7.1.14 ToPropertyKey
28
29 1. Let key be ? ToPrimitive(argument, hint String).
30
31 7.1.1 ToPrimitive
32
33 [...]
34 7. Return ? OrdinaryToPrimitive(input, hint).
35
36 7.1.1.1 OrdinaryToPrimitive
37
38 5. For each name in methodNames in List order, do
39 [...]
40 6. Throw a TypeError exception.
41 ---*/
42 var badKey = Object.create(null);
43
44
45 assert.throws(TypeError, function() {
46 ({
47 get [badKey]() {}
48 });
49 }, '`get` accessor');
50
51 assert.throws(TypeError, function() {
52 ({
53 set [badKey](_) {}
54 });
55 }, '`set` accessor');
56
57 reportCompare(0, 0);