| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Flags: --harmony-computed-property-names --allow-natives-syntax | |
| 6 | |
| 7 | |
| 8 function ID(x) { | |
| 9 return x; | |
| 10 } | |
| 11 | |
| 12 | |
| 13 (function TestComputedMethodSuper() { | |
| 14 var proto = { | |
| 15 m() { | |
| 16 return ' proto m'; | |
| 17 } | |
| 18 }; | |
| 19 var object = { | |
| 20 __proto__: proto, | |
| 21 ['a']() { return 'a' + super.m(); }, | |
| 22 [ID('b')]() { return 'b' + super.m(); }, | |
| 23 [0]() { return '0' + super.m(); }, | |
| 24 [ID(1)]() { return '1' + super.m(); }, | |
| 25 }; | |
| 26 | |
| 27 assertSame(object, object.a[%HomeObjectSymbol()]); | |
| 28 | |
| 29 assertEquals('a proto m', object.a()); | |
| 30 assertEquals('b proto m', object.b()); | |
| 31 assertEquals('0 proto m', object[0]()); | |
| 32 assertEquals('1 proto m', object[1]()); | |
| 33 })(); | |
| 34 | |
| 35 | |
| 36 (function TestComputedGetterSuper() { | |
| 37 var proto = { | |
| 38 m() { | |
| 39 return ' proto m'; | |
| 40 } | |
| 41 }; | |
| 42 var object = { | |
| 43 __proto__: proto, | |
| 44 get ['a']() { return 'a' + super.m(); }, | |
| 45 get [ID('b')]() { return 'b' + super.m(); }, | |
| 46 get [0]() { return '0' + super.m(); }, | |
| 47 get [ID(1)]() { return '1' + super.m(); }, | |
| 48 }; | |
| 49 assertEquals('a proto m', object.a); | |
| 50 assertEquals('b proto m', object.b); | |
| 51 assertEquals('0 proto m', object[0]); | |
| 52 assertEquals('1 proto m', object[1]); | |
| 53 })(); | |
| 54 | |
| 55 | |
| 56 (function TestComputedSetterSuper() { | |
| 57 var value; | |
| 58 var proto = { | |
| 59 m(name, v) { | |
| 60 value = name + ' ' + v; | |
| 61 } | |
| 62 }; | |
| 63 var object = { | |
| 64 __proto__: proto, | |
| 65 set ['a'](v) { super.m('a', v); }, | |
| 66 set [ID('b')](v) { super.m('b', v); }, | |
| 67 set [0](v) { super.m('0', v); }, | |
| 68 set [ID(1)](v) { super.m('1', v); }, | |
| 69 }; | |
| 70 object.a = 2; | |
| 71 assertEquals('a 2', value); | |
| 72 object.b = 3; | |
| 73 assertEquals('b 3', value); | |
| 74 object[0] = 4; | |
| 75 assertEquals('0 4', value); | |
| 76 object[1] = 5; | |
| 77 assertEquals('1 5', value); | |
| 78 })(); | |
| OLD | NEW |