| Index: test/mjsunit/harmony/super.js
|
| diff --git a/test/mjsunit/compiler/property-static.js b/test/mjsunit/harmony/super.js
|
| similarity index 55%
|
| copy from test/mjsunit/compiler/property-static.js
|
| copy to test/mjsunit/harmony/super.js
|
| index 07021340cd7aa94440638f925eeed921ee78c9c7..594eaf5f52d86b6667272abd5121b0e168616961 100644
|
| --- a/test/mjsunit/compiler/property-static.js
|
| +++ b/test/mjsunit/harmony/super.js
|
| @@ -1,3 +1,4 @@
|
| +
|
| // Copyright 2013 the V8 project authors. All rights reserved.
|
| // Redistribution and use in source and binary forms, with or without
|
| // modification, are permitted provided that the following conditions are
|
| @@ -24,46 +25,47 @@
|
| // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| -
|
| +//
|
| // Flags: --allow-natives-syntax
|
|
|
| -// Test usage of static type information for loads that would otherwise
|
| -// turn into polymorphic or generic loads.
|
| -
|
| -// Prepare a highly polymorphic load to be used by all tests.
|
| -Object.prototype.load = function() { return this.property; };
|
| -Object.prototype.load.call({ A:0, property:10 });
|
| -Object.prototype.load.call({ A:0, B:0, property:11 });
|
| -Object.prototype.load.call({ A:0, B:0, C:0, property:12 });
|
| -Object.prototype.load.call({ A:0, B:0, C:0, D:0, property:13 });
|
| -Object.prototype.load.call({ A:0, B:0, C:0, D:0, E:0, property:14 });
|
| -Object.prototype.load.call({ A:0, B:0, C:0, D:0, E:0, F:0, property:15 });
|
|
|
| -// Test for object literals.
|
| (function() {
|
| - function f(x) {
|
| - var object = { property:x };
|
| - return object.load();
|
| - }
|
| + function Base() { }
|
| + function Derived() { }
|
| + Derived.prototype = Object.create(Base.prototype);
|
|
|
| - assertSame(1, f(1));
|
| - assertSame(2, f(2));
|
| - %OptimizeFunctionOnNextCall(f);
|
| - assertSame(3, f(3));
|
| -})();
|
| + function fBase() { return "Base " + this.toString(); }
|
| + Base.prototype.f = %ToMethod(fBase, 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]);
|
|
|
| -// Test for inlined constructors.
|
| -(function() {
|
| - function c(x) {
|
| - this.property = x;
|
| - }
|
| - function f(x) {
|
| - var object = new c(x);
|
| - return object.load();
|
| + return "Derived"
|
| }
|
|
|
| - assertSame(1, f(1));
|
| - assertSame(2, f(2));
|
| - %OptimizeFunctionOnNextCall(f);
|
| - assertSame(3, f(3));
|
| -})();
|
| + 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 = %ToMethod(fDerived, Derived.prototype);
|
| +
|
| + assertEquals("Base this is Base", new Base().f());
|
| + assertEquals("Derived", new Derived().f());
|
| +}());
|
|
|