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

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: 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/parser.cc ('K') | « src/runtime/runtime-classes.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 207 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
233 assertThrows(function() { Base1(); }, TypeError);
234
235 class Subclass1 extends Base1 { }
236
237 assertThrows(function() { Subclass1(); }, TypeError);
238
239 let s1 = new Subclass1();
240 assertSame(s1.__proto__, Subclass1.prototype);
241
242 class Base2 {
243 constructor(x, y) {
244 this.x = x;
245 this.y = y;
246 }
247 }
248
249 class Subclass2 extends Base2 {};
250
251 let s2 = new Subclass2(1, 2);
252
253 assertSame(s2.__proto__, Subclass2.prototype);
254 assertSame(1, s2.x);
255 assertSame(2, s2.y);
256
257 var f = Subclass2.bind({}, 3, 4);
arv (Not doing code reviews) 2015/02/11 14:53:49 var -> let
Dmitry Lomov (no reviews) 2015/02/11 16:29:36 Done.
258 let s2prime = new f();
259 assertSame(s2prime.__proto__, Subclass2.prototype);
260 assertSame(3, s2prime.x);
261 assertSame(4, s2prime.y);
262
263 let obj = {};
264 class Base3 {
265 constructor() {
266 return obj;
267 }
268 }
269
270 class Subclass3 extends Base3 {};
271
272 let s3 = new Subclass3();
273 assertSame(obj, s3);
274
275 class ExtendedUint8Array extends Uint8Array { }
276
277 var eua = new ExtendedUint8Array(10);
278 assertEquals(10, eua.length);
279 assertEquals(10, eua.byteLength);
280 eua[0] = 0xFF;
281 eua[1] = 0xFFA;
282 assertEquals(0xFF, eua[0]);
283 assertEquals(0xFA, eua[1]);
284 assertTrue(eua.__proto__ === ExtendedUint8Array.prototype);
arv (Not doing code reviews) 2015/02/11 14:53:49 assertSame or assertEquals
Dmitry Lomov (no reviews) 2015/02/11 16:29:36 Done.
285 assertEquals("[object Uint8Array]", Object.prototype.toString.call(eua));
286 }());
OLDNEW
« src/parser.cc ('K') | « src/runtime/runtime-classes.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698