| 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 |
In a class, static computed property method names can be a string |
| 7 |
includes: [compareArray.js] |
| 8 |
---*/ |
| 9 |
class C { |
| 10 |
static a() { return 'A'} |
| 11 |
static ['b']() { return 'B'; } |
| 12 |
static c() { return 'C'; } |
| 13 |
static ['d']() { return 'D'; } |
| 14 |
} |
| 15 |
assert.sameValue(C.a(), 'A', "`C.a()` returns `'A'`. Defined as `static a() { return 'A'}`"); |
| 16 |
assert.sameValue(C.b(), 'B', "`C.b()` returns `'B'`. Defined as `static ['b']() { return 'B'; }`"); |
| 17 |
assert.sameValue(C.c(), 'C', "`C.c()` returns `'C'`. Defined as `static c() { return 'C'; }`"); |
| 18 |
assert.sameValue(C.d(), 'D', "`C.d()` returns `'D'`. Defined as `static ['d']() { return 'D'; }`"); |
| 19 |
assert( |
| 20 |
compareArray(Object.keys(C), []), |
| 21 |
"`compareArray(Object.keys(C), [])` returns `true`" |
| 22 |
); |
| 23 |
assert( |
| 24 |
compareArray(Object.getOwnPropertyNames(C), ['length', 'prototype', 'a', 'b', 'c', 'd', 'name']), |
| 25 |
"`compareArray(Object.getOwnPropertyNames(C), ['length', 'prototype', 'a', 'b', 'c', 'd', 'name'])` returns `true`" |
| 26 |
); |