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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 //
5 // Flags: --harmony-classes
6
7
8 (function TestSuperKeyword() {
9 function Base() { }
10 function Derived() { }
11 Derived.prototype = Object.create(Base.prototype);
12
13 function fBase() { return "Base " + this.toString(); }
14
15 Base.prototype.f = fBase.toMethod(Base.prototype);
16
17 function fDerived() {
18 assertEquals("Base this is Derived", super.f());
19 assertEquals("128 from Base", super[128]());
20 assertEquals("128 from Derived", this[128]());
21 assertEquals(15, super.x);
22 assertEquals(27, this.x);
23 assertEquals(27, super[42]);
24 assertEquals(33, this[42]);
25 super.x = 5;
26 assertEquals(5, Base.prototype.x);
27 assertEquals(5, super.x);
28 assertEquals(27, this.x);
29 super[42] = 6;
30 assertEquals(6, Base.prototype[42]);
31 assertEquals(6, super[42]);
32 assertEquals(33, this[42]);
33
34 return "Derived"
35 }
36
37 Base.prototype.x = 15;
38 Base.prototype[42] = 27;
39 Base.prototype[128] = function() { return "128 from Base"; }
40 Derived.prototype[128] = function() { return "128 from Derived"; }
41 Base.prototype.toString = function() { return "this is Base"; };
42 Derived.prototype.toString = function() { return "this is Derived"; };
43 Derived.prototype.x = 27;
44 Derived.prototype[42] = 33;
45 Derived.prototype.f = fDerived.toMethod(Derived.prototype);
46
47 assertEquals("Base this is Base", new Base().f());
48 assertEquals("Derived", new Derived().f());
49 }());
50
51 (function TestSuperKeywordNonMethod() {
52 function f() {
53 super.unknown();
54 }
55
56 function g() {
57 super['unknown'] = 5;
58 }
59 assertThrows(f, ReferenceError);
60 assertThrows(g, ReferenceError);
61 }());
OLDNEW
« 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