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

Side by Side Diff: test/mjsunit/harmony/super.js

Issue 615043002: Desugar 'super(..)' into 'super.constructor(...)' (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « src/ast.h ('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: --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 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 assertEquals(4, super.x--); 467 assertEquals(4, super.x--);
468 assertEquals(3, super.x); 468 assertEquals(3, super.x);
469 assertEquals(2, --super.x); 469 assertEquals(2, --super.x);
470 assertEquals(2, super.x); 470 assertEquals(2, super.x);
471 assertEquals(2, this._x); 471 assertEquals(2, this._x);
472 }.toMethod(Derived.prototype); 472 }.toMethod(Derived.prototype);
473 new Derived().testCounts(); 473 new Derived().testCounts();
474 }()); 474 }());
475 475
476 476
477 (function TestSuperCall() {
478 function Subclass(base, constructor) {
479 var homeObject = { __proto__ : base.prototype };
480 var result = constructor.toMethod(homeObject);
481 homeObject.constructor = result;
482 result.prototype = homeObject;
483 return result;
484 }
485
486 var baseCalled = 0;
487 var derivedCalled = 0;
488 var derivedDerivedCalled = 0;
489
490 function Base() {
491 baseCalled++;
492 }
493
494 var Derived = Subclass(Base, function () {
495 super();
496 derivedCalled++;
497 });
498
499 assertEquals(Base, Base.prototype.constructor);
500 assertEquals(Base.prototype, Derived.prototype.__proto__);
501
502 baseCalled = 0;
503 derivedCalled = 0;
504 new Derived();
505 assertEquals(1, baseCalled);
506 assertEquals(1, derivedCalled);
507
508 var DerivedDerived = Subclass(Derived, function () {
509 super();
510 derivedDerivedCalled++;
511 });
512
513 baseCalled = 0;
514 derivedCalled = 0;
515 derivedDerivedCalled = 0;
516 new DerivedDerived();
517 assertEquals(1, baseCalled);
518 assertEquals(1, derivedCalled);
519 assertEquals(1, derivedDerivedCalled);
520
521 function Base2(v) {
522 this.fromBase = v;
523 }
524 var Derived2 = Subclass(Base2, function (v1, v2) {
525 super(v1);
526 this.fromDerived = v2;
527 });
528
529 var d = new Derived2("base", "derived");
530 assertEquals("base", d.fromBase);
531 assertEquals("derived", d.fromDerived);
532 }());
533
534
477 (function TestUnsupportedCases() { 535 (function TestUnsupportedCases() {
478 function f1(x) { return super[x]; } 536 function f1(x) { return super[x]; }
479 function f2(x) { super[x] = 5; } 537 function f2(x) { super[x] = 5; }
480 var o = {}; 538 var o = {};
481 assertThrows(function(){f1.toMethod(o)(x);}, ReferenceError); 539 assertThrows(function(){f1.toMethod(o)(x);}, ReferenceError);
482 assertThrows(function(){f2.toMethod(o)(x);}, ReferenceError); 540 assertThrows(function(){f2.toMethod(o)(x);}, ReferenceError);
483 }()); 541 }());
OLDNEW
« no previous file with comments | « src/ast.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698