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

Unified Diff: test/mjsunit/harmony/super.js

Issue 665773003: Classes: implement 'new super'. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: debug compilation fixed 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/x64/full-codegen-x64.cc ('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 a2e07ed032abd00ee4961ee8e2433af071c62891..d972407520ecda11269608609d185b0cbbc38ca8 100644
--- a/test/mjsunit/harmony/super.js
+++ b/test/mjsunit/harmony/super.js
@@ -1735,19 +1735,19 @@
}());
-(function TestSuperCall() {
- function Subclass(base, constructor) {
- var homeObject = {
- __proto__: base.prototype,
- constructor: constructor
- };
- constructor.__proto__ = base;
- constructor.prototype = homeObject;
- // not doing toMethod: home object is not required for
- // super constructor calls.
- return constructor;
- }
+function Subclass(base, constructor) {
+ var homeObject = {
+ __proto__: base.prototype,
+ constructor: constructor
+ };
+ constructor.__proto__ = base;
+ constructor.prototype = homeObject;
+ // not doing toMethod: home object is not required for
+ // super constructor calls.
+ return constructor;
+}
+(function TestSuperCall() {
var baseCalled = 0;
var derivedCalled = 0;
var derivedDerivedCalled = 0;
@@ -1819,6 +1819,32 @@
}());
+(function TestNewSuper() {
+ var baseCalled = 0;
+ var derivedCalled = 0;
+
+ function Base() {
+ baseCalled++;
+ this.x = 15;
+ }
+
+
+ var Derived = Subclass(Base, function() {
+ baseCalled = 0;
+ var b = new super();
+ assertEquals(1, baseCalled)
+ assertEquals(Base.prototype, b.__proto__);
+ assertEquals(15, b.x);
+ assertEquals(undefined, this.x);
+ derivedCalled++;
+ });
+
+ derivedCalled = 0;
+ new Derived();
+ assertEquals(1, derivedCalled);
+}());
+
+
(function TestSuperCallErrorCases() {
function T() {
super();
@@ -1828,4 +1854,10 @@
// we throw TypeError.
// Filed https://bugs.ecmascript.org/show_bug.cgi?id=3282
assertThrows(function() { new T(); }, TypeError);
+
+ function T1() {
+ var b = new super();
+ }
+ T1.__proto = null;
+ assertThrows(function() { new T1(); }, TypeError);
}());
« no previous file with comments | « src/x64/full-codegen-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698