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

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

Issue 661433002: Implement the new semantics for 'super(...)' (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: CR feedback 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 130c010a4db65f7e9d70e063c133317c55df72f4..c39944d29ab89007a225dd61e7ad1bd4b397fd1e 100644
--- a/test/mjsunit/harmony/super.js
+++ b/test/mjsunit/harmony/super.js
@@ -1192,11 +1192,15 @@
(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 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;
}
var baseCalled = 0;
@@ -1245,6 +1249,40 @@
var d = new Derived2("base", "derived");
assertEquals("base", d.fromBase);
assertEquals("derived", d.fromDerived);
+
+ function ImplicitSubclassOfFunction() {
+ super();
+ this.x = 123;
+ }
+
+ var o = new ImplicitSubclassOfFunction();
+ assertEquals(123, o.x);
+
+ var calls = 0;
+ function G() {
+ calls++;
+ }
+ function F() {
+ super();
+ }
+ F.__proto__ = G;
+ new F();
+ assertEquals(1, calls);
+ F.__proto__ = function() {};
+ new F();
+ assertEquals(1, calls);
+}());
+
+
+(function TestSuperCallErrorCases() {
+ function T() {
+ super();
+ }
+ T.__proto__ = null;
+ // Spec says ReferenceError here, but for other IsCallable failures
+ // we throw TypeError.
+ // Filed https://bugs.ecmascript.org/show_bug.cgi?id=3282
+ assertThrows(function() { new T(); }, 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