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

Unified 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, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ast.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/super.js
diff --git a/test/mjsunit/harmony/super.js b/test/mjsunit/harmony/super.js
index 5d3ee2b999385414853c70a5298817c460f1e347..735fb5fd9fe4f72b9bfa1ae2f16e30b293025b8d 100644
--- a/test/mjsunit/harmony/super.js
+++ b/test/mjsunit/harmony/super.js
@@ -474,6 +474,64 @@
}());
+(function TestSuperCall() {
+ function Subclass(base, constructor) {
+ var homeObject = { __proto__ : base.prototype };
+ var result = constructor.toMethod(homeObject);
+ homeObject.constructor = result;
+ result.prototype = homeObject;
+ return result;
+ }
+
+ var baseCalled = 0;
+ var derivedCalled = 0;
+ var derivedDerivedCalled = 0;
+
+ function Base() {
+ baseCalled++;
+ }
+
+ var Derived = Subclass(Base, function () {
+ super();
+ derivedCalled++;
+ });
+
+ assertEquals(Base, Base.prototype.constructor);
+ assertEquals(Base.prototype, Derived.prototype.__proto__);
+
+ baseCalled = 0;
+ derivedCalled = 0;
+ new Derived();
+ assertEquals(1, baseCalled);
+ assertEquals(1, derivedCalled);
+
+ var DerivedDerived = Subclass(Derived, function () {
+ super();
+ derivedDerivedCalled++;
+ });
+
+ baseCalled = 0;
+ derivedCalled = 0;
+ derivedDerivedCalled = 0;
+ new DerivedDerived();
+ assertEquals(1, baseCalled);
+ assertEquals(1, derivedCalled);
+ assertEquals(1, derivedDerivedCalled);
+
+ function Base2(v) {
+ this.fromBase = v;
+ }
+ var Derived2 = Subclass(Base2, function (v1, v2) {
+ super(v1);
+ this.fromDerived = v2;
+ });
+
+ var d = new Derived2("base", "derived");
+ assertEquals("base", d.fromBase);
+ assertEquals("derived", d.fromDerived);
+}());
+
+
(function TestUnsupportedCases() {
function f1(x) { return super[x]; }
function f2(x) { super[x] = 5; }
« 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