| 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 symbol |
| 7 |
includes: [compareArray.js] |
| 8 |
features: [Symbol] |
| 9 |
---*/ |
| 10 |
|
| 11 |
function ID(x) { |
| 12 |
return x; |
| 13 |
} |
| 14 |
|
| 15 |
var sym1 = Symbol(); |
| 16 |
var sym2 = Symbol(); |
| 17 |
class C { |
| 18 |
a() { return 'A'; } |
| 19 |
[sym1]() { return 'B'; } |
| 20 |
c() { return 'C'; } |
| 21 |
[ID(sym2)]() { return 'D'; } |
| 22 |
} |
| 23 |
assert.sameValue(new C().a(), 'A', "`new C().a()` returns `'A'`. Defined as `a() { return 'A'; }`"); |
| 24 |
assert.sameValue(new C()[sym1](), 'B', "`new C()[sym1]()` returns `'B'`. Defined as `[sym1]() { return 'B'; }`"); |
| 25 |
assert.sameValue(new C().c(), 'C', "`new C().c()` returns `'C'`. Defined as `c() { return 'C'; }`"); |
| 26 |
assert.sameValue(new C()[sym2](), 'D', "`new C()[sym2]()` returns `'D'`. Defined as `[ID(sym2)]() { return 'D'; }`"); |
| 27 |
assert( |
| 28 |
compareArray(Object.keys(C.prototype), []), |
| 29 |
"`compareArray(Object.keys(C.prototype), [])` returns `true`" |
| 30 |
); |
| 31 |
assert( |
| 32 |
compareArray(Object.getOwnPropertyNames(C.prototype), ['constructor', 'a', 'c']), |
| 33 |
"`compareArray(Object.getOwnPropertyNames(C.prototype), ['constructor', 'a', 'c'])` returns `true`" |
| 34 |
); |
| 35 |
assert( |
| 36 |
compareArray(Object.getOwnPropertySymbols(C.prototype), [sym1, sym2]), |
| 37 |
"`compareArray(Object.getOwnPropertySymbols(C.prototype), [sym1, sym2])` returns `true`" |
| 38 |
); |