Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/computed-property-names/basics/number.js

raw
1 // Copyright (C) 2014 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 es6id: 12.2.5
5 description: >
6 computed property names can be a number
7 includes: [compareArray.js]
8 ---*/
9
10 function ID(x) {
11 return x;
12 }
13
14 var object = {
15 a: 'A',
16 [1]: 'B',
17 c: 'C',
18 [ID(2)]: 'D',
19 };
20 assert.sameValue(object.a, 'A', "The value of `object.a` is `'A'`. Defined in `object` as `a: 'A'`");
21 assert.sameValue(object[1], 'B', "The value of `object[1]` is `'B'`. Defined in `object` as `[1]: 'B'`");
22 assert.sameValue(object.c, 'C', "The value of `object.c` is `'C'`. Defined in `object` as `c: 'C'`");
23 assert.sameValue(object[2], 'D', "The value of `object[2]` is `'D'`. Defined in `object` as `[ID(2)]: 'D'`");
24 assert(
25 compareArray(Object.keys(object), ['1', '2', 'a', 'c']),
26 "`compareArray(Object.keys(object), ['1', '2', 'a', 'c'])` returns `true`"
27 );