| 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 class method names can be a number |
| 7 |
includes: [compareArray.js] |
| 8 |
---*/ |
| 9 |
|
| 10 |
function ID(x) { |
| 11 |
return x; |
| 12 |
} |
| 13 |
|
| 14 |
class C { |
| 15 |
a() { return 'A'; } |
| 16 |
[1]() { return 'B'; } |
| 17 |
c() { return 'C'; } |
| 18 |
[ID(2)]() { return 'D'; } |
| 19 |
} |
| 20 |
assert.sameValue(new C().a(), 'A', "`new C().a()` returns `'A'`, from `a() { return 'A'; }`"); |
| 21 |
assert.sameValue(new C()[1](), 'B', "`new C()[1]()` returns `'B'`, from `[1]() { return 'B'; }`"); |
| 22 |
assert.sameValue(new C().c(), 'C', "`new C().c()` returns `'C'`, from `c() { return 'C'; }`"); |
| 23 |
assert.sameValue(new C()[2](), 'D', "`new C()[2]()` returns `'D'`, from `[ID(2)]() { return 'D'; }`"); |
| 24 |
assert( |
| 25 |
compareArray(Object.keys(C.prototype), []), |
| 26 |
"`compareArray(Object.keys(C.prototype), [])` returns `true`" |
| 27 |
); |
| 28 |
assert( |
| 29 |
compareArray(Object.getOwnPropertyNames(C.prototype), ['1', '2', 'constructor', 'a', 'c']), |
| 30 |
"`compareArray(Object.getOwnPropertyNames(C.prototype), ['1', '2', 'constructor', 'a', 'c'])` returns `true`" |
| 31 |
); |