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

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

Issue 622523004: Support for super keyed loads where key is a name. (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
« src/runtime/runtime-classes.cc ('K') | « src/runtime/runtime-classes.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 35f6469442598bcce046af1a5d3e9c0d22349a12..8257688fbb80d9ff2df08fbd0fc1870689127639 100644
--- a/test/mjsunit/harmony/super.js
+++ b/test/mjsunit/harmony/super.js
@@ -37,6 +37,41 @@
}());
+(function TestSuperKeyedLoads() {
+ var x = 'x';
+ var derivedDataProperty = 'derivedDataProperty';
+ var f = 'f';
+ function Base() { }
+ function Derived() {
+ this[derivedDataProperty] = "xxx";
arv (Not doing code reviews) 2014/10/01 15:20:23 consistency
+ }
+ 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]());
+ var a = super[x];
+ assertEquals(15, a);
+ assertEquals(15, super[x]);
+ assertEquals(27, this[x]);
+
+ return "Derived"
+ }
+
+ Base.prototype[x] = 15;
+ Base.prototype.toString = function() { return "this is Base"; };
+ Derived.prototype.toString = function() { return "this is Derived"; };
+ Derived.prototype[x] = 27;
+ Derived.prototype[f] = fDerived.toMethod(Derived.prototype);
+
+ assertEquals("Base this is Base", new Base().f());
+ assertEquals("Derived", new Derived().f());
+}());
+
+
arv (Not doing code reviews) 2014/10/01 15:20:23 Can you add tests that uses numeric keys? Can you
(function TestSuperKeywordNonMethod() {
function f() {
super.unknown();
@@ -79,6 +114,40 @@
}());
+(function TestGetterKeyed() {
+ var x = 'x';
+ function Base() {}
+ var derived;
+ Base.prototype = {
+ constructor: Base,
+ get x() {
+ assertSame(this, derived);
+ return this._x;
+ },
+ _x: 'base'
+ };
+
+ function Derived() {}
+ Derived.__proto__ = Base;
+ Derived.prototype = {
+ __proto__: Base.prototype,
+ constructor: Derived,
+ _x: 'derived'
+ };
+ Derived.prototype.testGetter = function() {
+ return super[x];
+ }.toMethod(Derived.prototype);
+ Derived.prototype.testGetterStrict = function() {
+ 'use strict';
+ return super[x];
+ }.toMethod(Derived.prototype);
+ derived = new Derived();
+ assertEquals('derived', derived.testGetter());
+ derived = new Derived();
+ assertEquals('derived', derived.testGetterStrict());
+}());
+
+
(function TestSetter() {
function Base() {}
Base.prototype = {
« src/runtime/runtime-classes.cc ('K') | « src/runtime/runtime-classes.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698