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 6 7"use strong"; 8 9function testSuper(object) { 10 assertEquals(0, object.validLoad()); 11 assertThrows(function(){ return object.propertyLoad() }, TypeError); 12 assertThrows(function(){ return object.elementLoad() }, TypeError); 13 assertThrows(function(){ return object.accessorLoad() }, TypeError); 14} 15 16class A { 17 constructor() {} 18 foo() { 19 return 0; 20 } 21 get bar() { 22 return 0; 23 } 24 set baz(_) { 25 return; 26 } 27} 28 29class B extends A { 30 constructor() { 31 super(); 32 } 33 validLoad() { 34 return super.foo() + super.bar; 35 } 36 propertyLoad() { 37 return super.x; 38 } 39 elementLoad() { 40 return super[1]; 41 } 42 accessorLoad() { 43 return super.baz; 44 } 45} 46 47class C extends A { 48 constructor() { 49 super(); 50 this[1] = 0; 51 this.x = 0; 52 } 53 get baz() { 54 return 0; 55 } 56 validLoad() { 57 return super.foo() + super.bar; 58 } 59 propertyLoad() { 60 return super.x; 61 } 62 elementLoad() { 63 return super[1]; 64 } 65 accessorLoad() { 66 return super.baz; 67 } 68} 69 70let b = new B(); 71let c = new C(); 72testSuper(b); 73testSuper(c); 74 75let d = { 76 "0": 0, 77 foo: 0, 78 bar: (function(){return 0}), 79 get baz(){return 0}, 80 set qux(_){return} 81} 82 83let e = { 84 __proto__: d, 85 "1": 0, 86 x: 0, 87 get baz(){return 0}, 88 validLoad() { 89 return super[0] + super.foo + super.bar() + super.baz; 90 }, 91 propertyLoad() { 92 return super.x; 93 }, 94 elementLoad() { 95 return super[1]; 96 }, 97 accessorLoad() { 98 return super.qux; 99 } 100} 101 102testSuper(e); 103