| 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: 14.5 |
| 5 |
description: > |
| 6 |
class numeric property names |
| 7 |
---*/ |
| 8 |
function assertMethodDescriptor(object, name) { |
| 9 |
var desc = Object.getOwnPropertyDescriptor(object, name); |
| 10 |
assert.sameValue(desc.configurable, true, "The value of `desc.configurable` is `true`"); |
| 11 |
assert.sameValue(desc.enumerable, false, "The value of `desc.enumerable` is `false`"); |
| 12 |
assert.sameValue(desc.writable, true, "The value of `desc.writable` is `true`"); |
| 13 |
assert.sameValue(typeof desc.value, 'function', "`typeof desc.value` is `'function'`"); |
| 14 |
assert.sameValue('prototype' in desc.value, false, "The result of `'prototype' in desc.value` is `false`"); |
| 15 |
} |
| 16 |
|
| 17 |
function assertGetterDescriptor(object, name) { |
| 18 |
var desc = Object.getOwnPropertyDescriptor(object, name); |
| 19 |
assert.sameValue(desc.configurable, true, "The value of `desc.configurable` is `true`"); |
| 20 |
assert.sameValue(desc.enumerable, false, "The value of `desc.enumerable` is `false`"); |
| 21 |
assert.sameValue(typeof desc.get, 'function', "`typeof desc.get` is `'function'`"); |
| 22 |
assert.sameValue('prototype' in desc.get, false, "The result of `'prototype' in desc.get` is `false`"); |
| 23 |
assert.sameValue(desc.set, undefined, "The value of `desc.set` is `undefined`"); |
| 24 |
} |
| 25 |
|
| 26 |
function assertSetterDescriptor(object, name) { |
| 27 |
var desc = Object.getOwnPropertyDescriptor(object, name); |
| 28 |
assert.sameValue(desc.configurable, true, "The value of `desc.configurable` is `true`"); |
| 29 |
assert.sameValue(desc.enumerable, false, "The value of `desc.enumerable` is `false`"); |
| 30 |
assert.sameValue(typeof desc.set, 'function', "`typeof desc.set` is `'function'`"); |
| 31 |
assert.sameValue('prototype' in desc.set, false, "The result of `'prototype' in desc.set` is `false`"); |
| 32 |
assert.sameValue(desc.get, undefined, "The value of `desc.get` is `undefined`"); |
| 33 |
} |
| 34 |
|
| 35 |
class B { |
| 36 |
1() { return 1; } |
| 37 |
get 2() { return 2; } |
| 38 |
set 3(_) {} |
| 39 |
|
| 40 |
static 4() { return 4; } |
| 41 |
static get 5() { return 5; } |
| 42 |
static set 6(_) {} |
| 43 |
} |
| 44 |
|
| 45 |
assertMethodDescriptor(B.prototype, '1'); |
| 46 |
assertGetterDescriptor(B.prototype, '2'); |
| 47 |
assertSetterDescriptor(B.prototype, '3'); |
| 48 |
|
| 49 |
assertMethodDescriptor(B, '4'); |
| 50 |
assertGetterDescriptor(B, '5'); |
| 51 |
assertSetterDescriptor(B, '6'); |
| 52 |
|
| 53 |
class C extends B { |
| 54 |
1() { return super[1](); } |
| 55 |
get 2() { return super[2]; } |
| 56 |
static 4() { return super[4](); } |
| 57 |
static get 5() { return super[5]; } |
| 58 |
} |
| 59 |
|
| 60 |
assert.sameValue(new C()[1](), 1, "`new C()[1]()` returns `1`. Defined as `1() { return super[1](); }`"); |
| 61 |
assert.sameValue(new C()[2], 2, "The value of `new C()[2]` is `2`. Defined as `get 2() { return super[2]; }`"); |
| 62 |
assert.sameValue(C[4](), 4, "`C[4]()` returns `4`. Defined as `static 4() { return super[4](); }`"); |
| 63 |
assert.sameValue(C[5], 5, "The value of `C[5]` is `5`. Defined as `static get 5() { return super[5]; }`"); |
| 64 |
|
| 65 |
reportCompare(0, 0); |