| 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 getters can call super methods |
| 7 |
---*/ |
| 8 |
|
| 9 |
function ID(x) { |
| 10 |
return x; |
| 11 |
} |
| 12 |
|
| 13 |
var proto = { |
| 14 |
m() { |
| 15 |
return ' proto m'; |
| 16 |
} |
| 17 |
}; |
| 18 |
var object = { |
| 19 |
get ['a']() { return 'a' + super.m(); }, |
| 20 |
get [ID('b')]() { return 'b' + super.m(); }, |
| 21 |
get [0]() { return '0' + super.m(); }, |
| 22 |
get [ID(1)]() { return '1' + super.m(); }, |
| 23 |
}; |
| 24 |
|
| 25 |
Object.setPrototypeOf(object, proto); |
| 26 |
|
| 27 |
assert.sameValue( |
| 28 |
object.a, |
| 29 |
'a proto m', |
| 30 |
"The value of `object.a` is `'a proto m'`. Defined as `get ['a']() { return 'a' + super.m(); }`" |
| 31 |
); |
| 32 |
assert.sameValue( |
| 33 |
object.b, |
| 34 |
'b proto m', |
| 35 |
"The value of `object.b` is `'b proto m'`. Defined as `get [ID('b')]() { return 'b' + super.m(); }`" |
| 36 |
); |
| 37 |
assert.sameValue( |
| 38 |
object[0], |
| 39 |
'0 proto m', |
| 40 |
"The value of `object[0]` is `'0 proto m'`. Defined as `get [0]() { return '0' + super.m(); }`" |
| 41 |
); |
| 42 |
assert.sameValue( |
| 43 |
object[1], |
| 44 |
'1 proto m', |
| 45 |
"The value of `object[1]` is `'1 proto m'`. Defined as `get [ID(1)]() { return '1' + super.m(); }`" |
| 46 |
); |