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); |
}()); |
-*/ |