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

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: Platform ports finished 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
« src/ia32/full-codegen-ia32.cc ('K') | « 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..97f6116cdca501425b5353ab00181bd15fc82fad 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,26 @@
var d = new Derived2("base", "derived");
assertEquals("base", d.fromBase);
assertEquals("derived", d.fromDerived);
+
+ function ImplicitSubclassOfObject() {
+ super();
arv (Not doing code reviews) 2014/10/15 14:47:18 Just to be clear that I understand this. This one
Dmitry Lomov (no reviews) 2014/10/15 17:22:57 You are right, this has to be called ImplicitSubcl
+ this.x = 123;
+ }
+
+ var o = new ImplicitSubclassOfObject();
+ assertEquals(123, o.x);
+}());
+
+
+(function TestSuperCallErrorCases() {
+ function T() {
+ super();
+ }
+ T.__proto__ = null;
+ // Spec says ReferenceError here, but for other IsCallable failures
+ // we throw TypeError.
arv (Not doing code reviews) 2014/10/15 14:47:18 Completely agree. I was reading up on the changes
+ // Filed https://bugs.ecmascript.org/show_bug.cgi?id=3282
+ assertThrows(function() { new T(); }, TypeError);
}());
arv (Not doing code reviews) 2014/10/15 14:49:54 maybe add a test that mutates __proto__ and then u
Dmitry Lomov (no reviews) 2014/10/15 17:22:57 Done.
« src/ia32/full-codegen-ia32.cc ('K') | « src/x64/full-codegen-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698