Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/computed-property-names/object/method/string.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 string
7 includes: [compareArray.js]
8 ---*/
9
10 function ID(x) {
11 return x;
12 }
13
14 var object = {
15 a() { return 'A'},
16 ['b']() { return 'B'; },
17 c() { return 'C'; },
18 [ID('d')]() { return 'D'; },
19 };
20 assert.sameValue(object.a(), 'A', "`object.a()` returns `'A'`. Defined as `a() { return 'A'}`");
21 assert.sameValue(object.b(), 'B', "`object.b()` returns `'B'`. Defined as `['b']() { return 'B'; }`");
22 assert.sameValue(object.c(), 'C', "`object.c()` returns `'C'`. Defined as `c() { return 'C'; }`");
23 assert.sameValue(object.d(), 'D', "`object.d()` returns `'D'`. Defined as `[ID('d')]() { return 'D'; }`");
24 assert(
25 compareArray(Object.keys(object), ['a', 'b', 'c', 'd']),
26 "`compareArray(Object.keys(object), ['a', 'b', 'c', 'd'])` returns `true`"
27 );