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

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

Issue 495773002: Codegen for super.x and super[x] (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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/ia32/full-codegen-ia32.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
new file mode 100644
index 0000000000000000000000000000000000000000..938805ef5ad597e2d29916f4b02aa63373ac9edc
--- /dev/null
+++ b/test/mjsunit/harmony/super.js
@@ -0,0 +1,61 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// Flags: --harmony-classes
+
+
+(function TestSuperKeyword() {
+ function Base() { }
+ function Derived() { }
+ Derived.prototype = Object.create(Base.prototype);
+
+ function fBase() { return "Base " + this.toString(); }
+
+ Base.prototype.f = fBase.toMethod(Base.prototype);
+
+ function fDerived() {
+ assertEquals("Base this is Derived", super.f());
+ assertEquals("128 from Base", super[128]());
+ assertEquals("128 from Derived", this[128]());
+ assertEquals(15, super.x);
+ assertEquals(27, this.x);
+ assertEquals(27, super[42]);
+ assertEquals(33, this[42]);
+ super.x = 5;
+ assertEquals(5, Base.prototype.x);
+ assertEquals(5, super.x);
+ assertEquals(27, this.x);
+ super[42] = 6;
+ assertEquals(6, Base.prototype[42]);
+ assertEquals(6, super[42]);
+ assertEquals(33, this[42]);
+
+ return "Derived"
+ }
+
+ Base.prototype.x = 15;
+ Base.prototype[42] = 27;
+ Base.prototype[128] = function() { return "128 from Base"; }
+ Derived.prototype[128] = function() { return "128 from Derived"; }
+ Base.prototype.toString = function() { return "this is Base"; };
+ Derived.prototype.toString = function() { return "this is Derived"; };
+ Derived.prototype.x = 27;
+ Derived.prototype[42] = 33;
+ Derived.prototype.f = fDerived.toMethod(Derived.prototype);
+
+ assertEquals("Base this is Base", new Base().f());
+ assertEquals("Derived", new Derived().f());
+}());
+
+(function TestSuperKeywordNonMethod() {
+ function f() {
+ super.unknown();
+ }
+
+ function g() {
+ super['unknown'] = 5;
+ }
+ assertThrows(f, ReferenceError);
+ assertThrows(g, ReferenceError);
+}());
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698