Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/computed-property-names/object/method/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 method 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() { return 'A'; },
16 [1]() { return 'B'; },
17 c() { return 'C'; },
18 [ID(2)]() { return 'D'; },
19 };
20 assert.sameValue(object.a(), 'A', "`object.a()` returns `'A'`. Defined as `a() { return 'A'; }`");
21 assert.sameValue(object[1](), 'B', "`object[1]()` returns `'B'`. Defined as `[1]() { return 'B'; }`");
22 assert.sameValue(object.c(), 'C', "`object.c()` returns `'C'`. Defined as `c() { return 'C'; }`");
23 assert.sameValue(object[2](), 'D', "`object[2]()` returns `'D'`. Defined as `[ID(2)]() { return 'D'; }`");
24 assert(
25 compareArray(Object.keys(object), ['1', '2', 'a', 'c']),
26 "`compareArray(Object.keys(object), ['1', '2', 'a', 'c'])` returns `true`"
27 );