blob: 83a38f4224ec43dd3aff9e115714c8f7157c3fe9 [file] [log] [blame]
keith_miller@apple.combcc77f22016-07-15 06:03:25 +00001// 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/*---
4es6id: 12.2.5
5description: >
6 computed property method names can be a number
7includes: [compareArray.js]
8---*/
9
10function ID(x) {
11 return x;
12}
13
14var object = {
15 a() { return 'A'; },
16 [1]() { return 'B'; },
17 c() { return 'C'; },
18 [ID(2)]() { return 'D'; },
19};
20assert.sameValue(object.a(), 'A', "`object.a()` returns `'A'`. Defined as `a() { return 'A'; }`");
21assert.sameValue(object[1](), 'B', "`object[1]()` returns `'B'`. Defined as `[1]() { return 'B'; }`");
22assert.sameValue(object.c(), 'C', "`object.c()` returns `'C'`. Defined as `c() { return 'C'; }`");
23assert.sameValue(object[2](), 'D', "`object[2]()` returns `'D'`. Defined as `[ID(2)]() { return 'D'; }`");
24assert(
25 compareArray(Object.keys(object), ['1', '2', 'a', 'c']),
26 "`compareArray(Object.keys(object), ['1', '2', 'a', 'c'])` returns `true`"
27);