| 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: --allow-natives-syntax | 5 // Flags: --allow-natives-syntax |
| 6 // Flags: --harmony-destructuring --harmony-rest-parameters --harmony-sloppy | 6 // Flags: --harmony-destructuring --harmony-rest-parameters --harmony-sloppy |
| 7 | 7 |
| 8 (function TestSuperNamedLoads() { | 8 (function TestSuperNamedLoads() { |
| 9 function Base() { } | 9 function Base() { } |
| 10 function fBase() { } | 10 function fBase() { } |
| (...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 932 | 932 |
| 933 | 933 |
| 934 (function TestSetterCreatingOwnPropertiesReconfigurable() { | 934 (function TestSetterCreatingOwnPropertiesReconfigurable() { |
| 935 function Base() {} | 935 function Base() {} |
| 936 function Derived() {} | 936 function Derived() {} |
| 937 Derived.prototype = { | 937 Derived.prototype = { |
| 938 __proto__: Base.prototype, | 938 __proto__: Base.prototype, |
| 939 mSloppy() { | 939 mSloppy() { |
| 940 assertEquals(42, this.ownReadOnly); | 940 assertEquals(42, this.ownReadOnly); |
| 941 super.ownReadOnly = 55; | 941 super.ownReadOnly = 55; |
| 942 assertEquals(55, this.ownReadOnly); | 942 assertSame(undefined, super.ownReadOnly); |
| 943 var descr = Object.getOwnPropertyDescriptor(this, 'ownReadOnly'); | 943 assertEquals(42, this.ownReadOnly); |
| 944 assertEquals(55, descr.value); | |
| 945 assertTrue(descr.configurable); | |
| 946 assertFalse(descr.enumerable); | |
| 947 assertFalse(descr.writable); | |
| 948 assertFalse(Base.prototype.hasOwnProperty('ownReadOnly')); | 944 assertFalse(Base.prototype.hasOwnProperty('ownReadOnly')); |
| 949 | 945 |
| 950 assertEquals(15, this.ownReadonlyAccessor); | 946 assertEquals(15, this.ownReadonlyAccessor); |
| 951 super.ownReadonlyAccessor = 25; | 947 super.ownReadonlyAccessor = 25; |
| 952 assertSame(undefined, super.ownReadonlyAccessor); | 948 assertSame(undefined, super.ownReadonlyAccessor); |
| 953 assertEquals(15, this.ownReadonlyAccessor); | 949 assertEquals(15, this.ownReadonlyAccessor); |
| 954 assertFalse(Base.prototype.hasOwnProperty('ownReadonlyAccessor')); | 950 assertFalse(Base.prototype.hasOwnProperty('ownReadonlyAccessor')); |
| 955 | 951 |
| 956 super.ownSetter = 35; | 952 super.ownSetter = 35; |
| 957 assertSame(undefined, super.ownSetter); | 953 assertSame(undefined, super.ownSetter); |
| 958 var descr = Object.getOwnPropertyDescriptor(this, 'ownSetter'); | 954 var descr = Object.getOwnPropertyDescriptor(this, 'ownSetter'); |
| 959 assertTrue('set' in descr); | 955 assertTrue('set' in descr); |
| 960 assertFalse(Base.prototype.hasOwnProperty('ownSetter')); | 956 assertFalse(Base.prototype.hasOwnProperty('ownSetter')); |
| 961 }, | 957 }, |
| 962 mStrict() { | 958 mStrict() { |
| 963 'use strict'; | 959 'use strict'; |
| 964 assertEquals(42, this.ownReadOnly); | 960 assertEquals(42, this.ownReadOnly); |
| 965 super.ownReadOnly = 55; | 961 assertThrows(() => {super.ownReadOnly = 55}, TypeError); |
| 966 assertEquals(55, this.ownReadOnly); | 962 assertSame(undefined, super.ownReadOnly); |
| 967 var descr = Object.getOwnPropertyDescriptor(this, 'ownReadOnly'); | 963 assertEquals(42, this.ownReadOnly); |
| 968 assertEquals(55, descr.value); | |
| 969 assertTrue(descr.configurable); | |
| 970 assertFalse(descr.enumerable); | |
| 971 assertFalse(descr.writable); | |
| 972 assertFalse(Base.prototype.hasOwnProperty('ownReadOnly')); | 964 assertFalse(Base.prototype.hasOwnProperty('ownReadOnly')); |
| 973 | 965 |
| 974 assertEquals(15, this.ownReadonlyAccessor); | 966 assertEquals(15, this.ownReadonlyAccessor); |
| 975 assertThrows(() => {super.ownReadonlyAccessor = 25}, TypeError); | 967 assertThrows(() => {super.ownReadonlyAccessor = 25}, TypeError); |
| 976 assertSame(undefined, super.ownReadonlyAccessor); | 968 assertSame(undefined, super.ownReadonlyAccessor); |
| 977 assertEquals(15, this.ownReadonlyAccessor); | 969 assertEquals(15, this.ownReadonlyAccessor); |
| 978 assertFalse(Base.prototype.hasOwnProperty('ownReadonlyAccessor')); | 970 assertFalse(Base.prototype.hasOwnProperty('ownReadonlyAccessor')); |
| 979 | 971 |
| 980 assertThrows(() => {super.ownSetter = 35}, TypeError); | 972 assertThrows(() => {super.ownSetter = 35}, TypeError); |
| 981 assertSame(undefined, super.ownSetter); | 973 assertSame(undefined, super.ownSetter); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1160 | 1152 |
| 1161 function TestKeyedSetterCreatingOwnPropertiesReconfigurable(ownReadOnly, | 1153 function TestKeyedSetterCreatingOwnPropertiesReconfigurable(ownReadOnly, |
| 1162 ownReadonlyAccessor, ownSetter) { | 1154 ownReadonlyAccessor, ownSetter) { |
| 1163 function Base() {} | 1155 function Base() {} |
| 1164 function Derived() {} | 1156 function Derived() {} |
| 1165 Derived.prototype = { | 1157 Derived.prototype = { |
| 1166 __proto__: Base.prototype, | 1158 __proto__: Base.prototype, |
| 1167 mSloppy() { | 1159 mSloppy() { |
| 1168 assertEquals(42, this[ownReadOnly]); | 1160 assertEquals(42, this[ownReadOnly]); |
| 1169 super[ownReadOnly] = 55; | 1161 super[ownReadOnly] = 55; |
| 1170 assertEquals(55, this[ownReadOnly]); | 1162 assertSame(undefined, super[ownReadOnly]); |
| 1171 var descr = Object.getOwnPropertyDescriptor(this, ownReadOnly); | 1163 assertEquals(42, this[ownReadOnly]); |
| 1172 assertEquals(55, descr.value); | |
| 1173 assertTrue(descr.configurable); | |
| 1174 assertFalse(descr.enumerable); | |
| 1175 assertFalse(descr.writable); | |
| 1176 assertFalse(Base.prototype.hasOwnProperty(ownReadOnly)); | 1164 assertFalse(Base.prototype.hasOwnProperty(ownReadOnly)); |
| 1177 | 1165 |
| 1178 assertEquals(15, this[ownReadonlyAccessor]); | 1166 assertEquals(15, this[ownReadonlyAccessor]); |
| 1179 super[ownReadonlyAccessor] = 25; | 1167 super[ownReadonlyAccessor] = 25; |
| 1180 assertSame(undefined, super[ownReadonlyAccessor]); | 1168 assertSame(undefined, super[ownReadonlyAccessor]); |
| 1181 assertEquals(15, this[ownReadonlyAccessor]); | 1169 assertEquals(15, this[ownReadonlyAccessor]); |
| 1182 assertFalse(Base.prototype.hasOwnProperty(ownReadonlyAccessor)); | 1170 assertFalse(Base.prototype.hasOwnProperty(ownReadonlyAccessor)); |
| 1183 | 1171 |
| 1184 super[ownSetter] = 35; | 1172 super[ownSetter] = 35; |
| 1185 assertSame(undefined, super[ownSetter]); | 1173 assertSame(undefined, super[ownSetter]); |
| 1186 var descr = Object.getOwnPropertyDescriptor(this, ownSetter); | 1174 var descr = Object.getOwnPropertyDescriptor(this, ownSetter); |
| 1187 assertTrue('set' in descr); | 1175 assertTrue('set' in descr); |
| 1188 assertFalse(Base.prototype.hasOwnProperty(ownSetter)); | 1176 assertFalse(Base.prototype.hasOwnProperty(ownSetter)); |
| 1189 }, | 1177 }, |
| 1190 mStrict() { | 1178 mStrict() { |
| 1191 'use strict'; | 1179 'use strict'; |
| 1192 assertEquals(42, this[ownReadOnly]); | 1180 assertEquals(42, this[ownReadOnly]); |
| 1193 super[ownReadOnly] = 55; | 1181 assertThrows(() => {super[ownReadOnly] = 55}, TypeError); |
| 1194 assertEquals(55, this[ownReadOnly]); | 1182 assertSame(undefined, super[ownReadOnly]); |
| 1195 var descr = Object.getOwnPropertyDescriptor(this, ownReadOnly); | 1183 assertEquals(42, this[ownReadOnly]); |
| 1196 assertEquals(55, descr.value); | |
| 1197 assertTrue(descr.configurable); | |
| 1198 assertFalse(descr.enumerable); | |
| 1199 assertFalse(descr.writable); | |
| 1200 assertFalse(Base.prototype.hasOwnProperty(ownReadOnly)); | 1184 assertFalse(Base.prototype.hasOwnProperty(ownReadOnly)); |
| 1201 | 1185 |
| 1202 assertEquals(15, this[ownReadonlyAccessor]); | 1186 assertEquals(15, this[ownReadonlyAccessor]); |
| 1203 assertThrows(() => {super[ownReadonlyAccessor] = 25}, TypeError); | 1187 assertThrows(() => {super[ownReadonlyAccessor] = 25}, TypeError); |
| 1204 assertSame(undefined, super[ownReadonlyAccessor]); | 1188 assertSame(undefined, super[ownReadonlyAccessor]); |
| 1205 assertEquals(15, this[ownReadonlyAccessor]); | 1189 assertEquals(15, this[ownReadonlyAccessor]); |
| 1206 assertFalse(Base.prototype.hasOwnProperty(ownReadonlyAccessor)); | 1190 assertFalse(Base.prototype.hasOwnProperty(ownReadonlyAccessor)); |
| 1207 | 1191 |
| 1208 assertThrows(() => {super[ownSetter] = 35}, TypeError); | 1192 assertThrows(() => {super[ownSetter] = 35}, TypeError); |
| 1209 assertSame(undefined, super[ownSetter]); | 1193 assertSame(undefined, super[ownSetter]); |
| (...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2223 } | 2207 } |
| 2224 class Derived extends Base { | 2208 class Derived extends Base { |
| 2225 constructor(x) { | 2209 constructor(x) { |
| 2226 let r = (() => super(...[x]))(); | 2210 let r = (() => super(...[x]))(); |
| 2227 assertEquals(this, r); | 2211 assertEquals(this, r); |
| 2228 } | 2212 } |
| 2229 } | 2213 } |
| 2230 let d = new Derived(42); | 2214 let d = new Derived(42); |
| 2231 assertSame(42, d.x); | 2215 assertSame(42, d.x); |
| 2232 })(); | 2216 })(); |
| OLD | NEW |