| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // Flags: --harmony-classes | 5 // Flags: --harmony-classes |
| 6 | 6 |
| 7 | 7 |
| 8 (function TestSuperNamedLoads() { | 8 (function TestSuperNamedLoads() { |
| 9 function Base() { } | 9 function Base() { } |
| 10 function Derived() { | 10 function Derived() { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 d.testSetterStrict(); | 116 d.testSetterStrict(); |
| 117 assertEquals('base', Base.prototype._x); | 117 assertEquals('base', Base.prototype._x); |
| 118 assertEquals('foobarabc', d._x); | 118 assertEquals('foobarabc', d._x); |
| 119 }()); | 119 }()); |
| 120 | 120 |
| 121 | 121 |
| 122 (function TestSetterDataProperties() { | 122 (function TestSetterDataProperties() { |
| 123 function Base() {} | 123 function Base() {} |
| 124 Base.prototype = { | 124 Base.prototype = { |
| 125 constructor: Base, | 125 constructor: Base, |
| 126 x : "x from Base" | 126 x: 'x from Base' |
| 127 }; | 127 }; |
| 128 | 128 |
| 129 function Derived() {} | 129 function Derived() {} |
| 130 Derived.prototype = { | 130 Derived.prototype = { |
| 131 __proto__: Base.prototype, | 131 __proto__: Base.prototype, |
| 132 constructor: Derived, | 132 constructor: Derived, |
| 133 }; | 133 }; |
| 134 | 134 |
| 135 Derived.prototype.testSetter = function() { | 135 Derived.prototype.testSetter = function() { |
| 136 assertEquals("x from Base", super.x); | 136 assertEquals('x from Base', super.x); |
| 137 super.x = "data property"; | 137 super.x = 'data property'; |
| 138 assertEquals("x from Base", super.x); | 138 assertEquals('x from Base', super.x); |
| 139 assertEquals("data property", this.x); | 139 assertEquals('data property', this.x); |
| 140 }.toMethod(Derived.prototype); | 140 }.toMethod(Derived.prototype); |
| 141 | 141 |
| 142 new Derived().testSetter(); | 142 new Derived().testSetter(); |
| 143 }()); | 143 }()); |
| 144 | 144 |
| 145 | 145 |
| 146 (function TestAccessorsOnPrimitives() { | 146 (function TestAccessorsOnPrimitives() { |
| 147 var getCalled = 0; | 147 var getCalled = 0; |
| 148 var setCalled = 0; | 148 var setCalled = 0; |
| 149 function Base() {} | 149 function Base() {} |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 assertEquals(1, getCalled); | 201 assertEquals(1, getCalled); |
| 202 assertEquals(1, setCalled); | 202 assertEquals(1, setCalled); |
| 203 | 203 |
| 204 assertEquals(6, super.x += 5); | 204 assertEquals(6, super.x += 5); |
| 205 assertEquals(2, getCalled); | 205 assertEquals(2, getCalled); |
| 206 assertEquals(2, setCalled); | 206 assertEquals(2, setCalled); |
| 207 | 207 |
| 208 var ex; | 208 var ex; |
| 209 try { | 209 try { |
| 210 super.newProperty = 15; | 210 super.newProperty = 15; |
| 211 } catch(e) { ex = e; } | 211 } catch (e) { ex = e; } |
| 212 assertTrue(ex instanceof TypeError); | 212 assertTrue(ex instanceof TypeError); |
| 213 }.toMethod(Derived.prototype); | 213 }.toMethod(Derived.prototype); |
| 214 | 214 |
| 215 Derived.prototype.testSetter.call(42); | 215 Derived.prototype.testSetter.call(42); |
| 216 Derived.prototype.testSetterStrict.call(42); | 216 Derived.prototype.testSetterStrict.call(42); |
| 217 | 217 |
| 218 function DerivedFromString() {} | 218 function DerivedFromString() {} |
| 219 DerivedFromString.prototype = Object.create(String.prototype); | 219 DerivedFromString.prototype = Object.create(String.prototype); |
| 220 | 220 |
| 221 function f() { | 221 function f() { |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 }()); | 474 }()); |
| 475 | 475 |
| 476 | 476 |
| 477 (function TestUnsupportedCases() { | 477 (function TestUnsupportedCases() { |
| 478 function f1(x) { return super[x]; } | 478 function f1(x) { return super[x]; } |
| 479 function f2(x) { super[x] = 5; } | 479 function f2(x) { super[x] = 5; } |
| 480 var o = {}; | 480 var o = {}; |
| 481 assertThrows(function(){f1.toMethod(o)(x);}, ReferenceError); | 481 assertThrows(function(){f1.toMethod(o)(x);}, ReferenceError); |
| 482 assertThrows(function(){f2.toMethod(o)(x);}, ReferenceError); | 482 assertThrows(function(){f2.toMethod(o)(x);}, ReferenceError); |
| 483 }()); | 483 }()); |
| OLD | NEW |