Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(345)

Side by Side Diff: test/mjsunit/harmony/classes-experimental.js

Issue 917753002: new classes: implement default constructors. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase to run try jobs Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« src/x64/code-stubs-x64.cc ('K') | « src/x64/full-codegen-x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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: --experimental-classes --harmony-classes 5 // Flags: --experimental-classes --harmony-classes
6 6
7 'use strict'; 7 'use strict';
8 (function TestArgumentsAccess() { 8 (function TestArgumentsAccess() {
9 class Base { 9 class Base {
10 constructor() { 10 constructor() {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 this[0] = 255; 165 this[0] = 255;
166 this[1] = 0xFFA; 166 this[1] = 0xFFA;
167 } 167 }
168 } 168 }
169 169
170 var eua = new ExtendedUint8Array(); 170 var eua = new ExtendedUint8Array();
171 assertEquals(10, eua.length); 171 assertEquals(10, eua.length);
172 assertEquals(10, eua.byteLength); 172 assertEquals(10, eua.byteLength);
173 assertEquals(0xFF, eua[0]); 173 assertEquals(0xFF, eua[0]);
174 assertEquals(0xFA, eua[1]); 174 assertEquals(0xFA, eua[1]);
175 assertTrue(eua.__proto__ === ExtendedUint8Array.prototype); 175 assertSame(ExtendedUint8Array.prototype, eua.__proto__);
176 assertEquals("[object Uint8Array]", Object.prototype.toString.call(eua)); 176 assertEquals("[object Uint8Array]", Object.prototype.toString.call(eua));
177 }()); 177 }());
178 178
179 (function TestSubclassingNull() { 179 (function TestSubclassingNull() {
180 let N = null; 180 let N = null;
181 181
182 class Foo extends N { 182 class Foo extends N {
183 constructor(x,y) { 183 constructor(x,y) {
184 assertSame(1, x); 184 assertSame(1, x);
185 assertSame(2, y); 185 assertSame(2, y);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 assertSame(undefined, s1.y); 218 assertSame(undefined, s1.y);
219 assertSame(Subclass.prototype, s1.__proto__); 219 assertSame(Subclass.prototype, s1.__proto__);
220 220
221 let g = Subclass.bind(obj, 1); 221 let g = Subclass.bind(obj, 1);
222 assertThrows(function () { g(8); }, TypeError); 222 assertThrows(function () { g(8); }, TypeError);
223 let s2 = new g(8); 223 let s2 = new g(8);
224 assertSame(1, s2.x); 224 assertSame(1, s2.x);
225 assertSame(8, s2.y); 225 assertSame(8, s2.y);
226 assertSame(Subclass.prototype, s.__proto__); 226 assertSame(Subclass.prototype, s.__proto__);
227 }()); 227 }());
228
229
230 (function TestDefaultConstructor() {
231 class Base1 { }
232 assertThrows(function() { Base1(); }, TypeError);
233
234 class Subclass1 extends Base1 { }
235
236 assertThrows(function() { Subclass1(); }, TypeError);
237
238 let s1 = new Subclass1();
239 assertSame(s1.__proto__, Subclass1.prototype);
240
241 class Base2 {
242 constructor(x, y) {
243 this.x = x;
244 this.y = y;
245 }
246 }
247
248 class Subclass2 extends Base2 {};
249
250 let s2 = new Subclass2(1, 2);
251
252 assertSame(s2.__proto__, Subclass2.prototype);
253 assertSame(1, s2.x);
254 assertSame(2, s2.y);
255
256 let f = Subclass2.bind({}, 3, 4);
257 let s2prime = new f();
258 assertSame(s2prime.__proto__, Subclass2.prototype);
259 assertSame(3, s2prime.x);
260 assertSame(4, s2prime.y);
261
262 let obj = {};
263 class Base3 {
264 constructor() {
265 return obj;
266 }
267 }
268
269 class Subclass3 extends Base3 {};
270
271 let s3 = new Subclass3();
272 assertSame(obj, s3);
273
274 class ExtendedUint8Array extends Uint8Array { }
275
276 var eua = new ExtendedUint8Array(10);
277 assertEquals(10, eua.length);
278 assertEquals(10, eua.byteLength);
279 eua[0] = 0xFF;
280 eua[1] = 0xFFA;
281 assertEquals(0xFF, eua[0]);
282 assertEquals(0xFA, eua[1]);
283 assertSame(ExtendedUint8Array.prototype, eua.__proto__);
284 assertEquals("[object Uint8Array]", Object.prototype.toString.call(eua));
285 }());
OLDNEW
« src/x64/code-stubs-x64.cc ('K') | « src/x64/full-codegen-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698