Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 1 | // Copyright 2015 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: --strong-mode --allow-natives-syntax |
| 6 | |
| 7 | 'use strong'; |
| 8 | |
| 9 | |
| 10 | function desc(obj, n) { |
| 11 | return Object.getOwnPropertyDescriptor(obj, n); |
| 12 | } |
| 13 | |
| 14 | |
| 15 | (function TestClass() { |
| 16 | class C { |
| 17 | m() { |
| 18 | super.x; |
| 19 | } |
| 20 | get x() { |
| 21 | super.x; |
| 22 | } |
| 23 | set y(_) { |
| 24 | super.x; |
| 25 | } |
| 26 | static m() { |
| 27 | super.x; |
| 28 | } |
| 29 | static get x() { |
| 30 | super.x; |
| 31 | } |
| 32 | static set y(_) { |
| 33 | super.x; |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | assertEquals(C.prototype, C.prototype.m[%HomeObjectSymbol()]); |
| 38 | assertEquals(C.prototype, desc(C.prototype, 'x').get[%HomeObjectSymbol()]); |
| 39 | assertEquals(C.prototype, desc(C.prototype, 'y').set[%HomeObjectSymbol()]); |
| 40 | assertEquals(C, C.m[%HomeObjectSymbol()]); |
| 41 | assertEquals(C, desc(C, 'x').get[%HomeObjectSymbol()]); |
| 42 | assertEquals(C, desc(C, 'y').set[%HomeObjectSymbol()]); |
| 43 | })(); |
| 44 | |
| 45 | |
| 46 | (function TestObjectLiteral() { |
| 47 | let o = { |
| 48 | m() { |
| 49 | super.x; |
| 50 | }, |
| 51 | get x() { |
| 52 | super.x; |
| 53 | }, |
| 54 | set y(_) { |
| 55 | super.x; |
| 56 | } |
| 57 | }; |
| 58 | |
| 59 | assertEquals(o, o.m[%HomeObjectSymbol()]); |
| 60 | assertEquals(o, desc(o, 'x').get[%HomeObjectSymbol()]); |
| 61 | assertEquals(o, desc(o, 'y').set[%HomeObjectSymbol()]); |
| 62 | })(); |