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

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

Issue 593073002: Stores and compound assignments for named super properties. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Tests for unsupported features 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.cc ('K') | « src/runtime.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 89fb4b1c1689ef60c1c6aec3813d4b09170d728b..8ebd3633aec78c804dec76c17f0843b88dcf286d 100644
--- a/test/mjsunit/harmony/super.js
+++ b/test/mjsunit/harmony/super.js
@@ -18,6 +18,8 @@
function fDerived() {
assertEquals("Base this is Derived", super.f());
+ var a = super.x;
+ assertEquals(15, a);
assertEquals(15, super.x);
assertEquals(27, this.x);
@@ -34,6 +36,7 @@
assertEquals("Derived", new Derived().f());
}());
+
(function TestSuperKeywordNonMethod() {
function f() {
super.unknown();
@@ -69,8 +72,7 @@
assertEquals('derived', derived.testGetter());
}());
-/*
- * TODO[dslomov]: named stores and keyed loads/stores not implemented yet.
+
(function TestSetter() {
function Base() {}
Base.prototype = {
@@ -92,36 +94,39 @@
_x: 'derived'
};
Derived.prototype.testSetter = function() {
Igor Sheludko 2014/09/25 08:06:02 Suggestion: test the strict mode too (and same for
- super.x = 'foobar';
- }.toMethod(Derived.prototype);
+ super.x = 'foobar';
+ super.x += 'abc';
+ }.toMethod(Derived.prototype);
var d = new Derived();
d.testSetter();
assertEquals('base', Base.prototype._x);
- assertEquals('foobar', d._x);
+ assertEquals('foobarabc', d._x);
}());
-(function TestKeyedGetter() {
+(function TestSetterFailures() {
function Base() {}
- Base.prototype = {
- constructor: Base,
- _x: 'base'
- };
+ function Derived() {}
+ Derived.prototype = { __proto__ : Base.prototype };
+ Derived.prototype.mSloppy = function () {
+ super.x = 10;
+ assertEquals(undefined, super.x);
+ }.toMethod(Derived.prototype);
- Object.defineProperty(Base.prototype, '0',
- { get: function() { return this._x; } });
+ Derived.prototype.mStrict = function () {
+ "use strict";
+ super.x = 10;
+ }.toMethod(Derived.prototype);
+ var d = new Derived();
+ d.mSloppy();
+ assertThrows(function() { d.mStrict(); }, ReferenceError);
Igor Sheludko 2014/09/25 08:06:02 Suggestion: use different instances of Derived for
+}());
- function Derived() {}
- Derived.__proto__ = Base;
- Derived.prototype = {
- __proto__: Base.prototype,
- constructor: Derived,
- _x: 'derived'
- };
- Derived.prototype.testGetter = function() {
- return super[0];
- }.toMethod(Derived.prototype);
- assertEquals('derived', new Derived()[0]);
- // assertEquals('derived', new Derived().testGetter());
+
+(function TestUnsupportedCases() {
+ function f1(x) { return super[x]; }
+ var o = {}
+ assertThrows(function(){f1.toMethod(o)(x);}, ReferenceError);
+ function f2() { super.x++; }
+ assertThrows(function(){f2.toMethod(o)();}, ReferenceError);
}());
-*/
« src/runtime.cc ('K') | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698