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

Side by Side Diff: test/mjsunit/harmony/super.js

Issue 1226123010: Represent implicit 'this' binding by 'super' in AST. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments. Created 5 years, 5 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
« no previous file with comments | « src/x87/full-codegen-x87.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
1 // Copyright 2014 the V8 project authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --harmony-arrow-functions --allow-natives-syntax 5 // Flags: --harmony-arrow-functions --allow-natives-syntax
6 // Flags: --harmony-spreadcalls 6 // Flags: --harmony-spreadcalls
7 7
8 (function TestSuperNamedLoads() { 8 (function TestSuperNamedLoads() {
9 function Base() { } 9 function Base() { }
10 function fBase() { } 10 function fBase() { }
(...skipping 1961 matching lines...) Expand 10 before | Expand all | Expand 10 after
1972 var derivedDerivedCalled = 0; 1972 var derivedDerivedCalled = 0;
1973 1973
1974 class Base { 1974 class Base {
1975 constructor() { 1975 constructor() {
1976 baseCalled++; 1976 baseCalled++;
1977 } 1977 }
1978 } 1978 }
1979 1979
1980 class Derived extends Base { 1980 class Derived extends Base {
1981 constructor() { 1981 constructor() {
1982 super(); 1982 let r = super();
1983 assertEquals(this, r);
1983 derivedCalled++; 1984 derivedCalled++;
1984 } 1985 }
1985 } 1986 }
1986 1987
1987 assertEquals(Base, Base.prototype.constructor); 1988 assertEquals(Base, Base.prototype.constructor);
1988 assertEquals(Base.prototype, Derived.prototype.__proto__); 1989 assertEquals(Base.prototype, Derived.prototype.__proto__);
1989 1990
1990 baseCalled = 0; 1991 baseCalled = 0;
1991 derivedCalled = 0; 1992 derivedCalled = 0;
1992 new Derived(); 1993 new Derived();
1993 assertEquals(1, baseCalled); 1994 assertEquals(1, baseCalled);
1994 assertEquals(1, derivedCalled); 1995 assertEquals(1, derivedCalled);
1995 1996
1996 class DerivedDerived extends Derived { 1997 class DerivedDerived extends Derived {
1997 constructor() { 1998 constructor() {
1998 super(); 1999 let r = super();
2000 assertEquals(this, r);
1999 derivedDerivedCalled++; 2001 derivedDerivedCalled++;
2000 } 2002 }
2001 } 2003 }
2002 2004
2003 baseCalled = 0; 2005 baseCalled = 0;
2004 derivedCalled = 0; 2006 derivedCalled = 0;
2005 derivedDerivedCalled = 0; 2007 derivedDerivedCalled = 0;
2006 new DerivedDerived(); 2008 new DerivedDerived();
2007 assertEquals(1, baseCalled); 2009 assertEquals(1, baseCalled);
2008 assertEquals(1, derivedCalled); 2010 assertEquals(1, derivedCalled);
2009 assertEquals(1, derivedDerivedCalled); 2011 assertEquals(1, derivedDerivedCalled);
2010 2012
2011 class Base2 { 2013 class Base2 {
2012 constructor(v) { 2014 constructor(v) {
2013 this.fromBase = v; 2015 this.fromBase = v;
2014 } 2016 }
2015 } 2017 }
2016 class Derived2 extends Base2 { 2018 class Derived2 extends Base2 {
2017 constructor(v1, v2) { 2019 constructor(v1, v2) {
2018 super(v1); 2020 let r = super(v1);
2021 assertEquals(this, r);
2019 this.fromDerived = v2; 2022 this.fromDerived = v2;
2020 } 2023 }
2021 } 2024 }
2022 2025
2023 var d = new Derived2("base", "derived"); 2026 var d = new Derived2("base", "derived");
2024 assertEquals("base", d.fromBase); 2027 assertEquals("base", d.fromBase);
2025 assertEquals("derived", d.fromDerived); 2028 assertEquals("derived", d.fromDerived);
2026 2029
2027 var calls = 0; 2030 var calls = 0;
2028 class G { 2031 class G {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
2121 2124
2122 (function TestSuperCallInEval() { 2125 (function TestSuperCallInEval() {
2123 'use strict'; 2126 'use strict';
2124 class Base { 2127 class Base {
2125 constructor(x) { 2128 constructor(x) {
2126 this.x = x; 2129 this.x = x;
2127 } 2130 }
2128 } 2131 }
2129 class Derived extends Base { 2132 class Derived extends Base {
2130 constructor(x) { 2133 constructor(x) {
2131 eval('super(x)'); 2134 let r = eval('super(x)');
2135 assertEquals(this, r);
2132 } 2136 }
2133 } 2137 }
2134 let d = new Derived(42); 2138 let d = new Derived(42);
2135 assertSame(42, d.x); 2139 assertSame(42, d.x);
2136 })(); 2140 })();
2137 2141
2138 2142
2139 (function TestSuperCallInArrow() { 2143 (function TestSuperCallInArrow() {
2140 'use strict'; 2144 'use strict';
2141 class Base { 2145 class Base {
2142 constructor(x) { 2146 constructor(x) {
2143 this.x = x; 2147 this.x = x;
2144 } 2148 }
2145 } 2149 }
2146 class Derived extends Base { 2150 class Derived extends Base {
2147 constructor(x) { 2151 constructor(x) {
2148 (() => super(x))(); 2152 let r = (() => super(x))();
2153 assertEquals(this, r);
2149 } 2154 }
2150 } 2155 }
2151 let d = new Derived(42); 2156 let d = new Derived(42);
2152 assertSame(42, d.x); 2157 assertSame(42, d.x);
2153 })(); 2158 })();
2154 2159
2155 2160
2156 (function TestSuperCallEscapes() { 2161 (function TestSuperCallEscapes() {
2157 'use strict'; 2162 'use strict';
2158 class Base { 2163 class Base {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
2224 2229
2225 (function TestSuperCallSpreadInEval() { 2230 (function TestSuperCallSpreadInEval() {
2226 'use strict'; 2231 'use strict';
2227 class Base { 2232 class Base {
2228 constructor(x) { 2233 constructor(x) {
2229 this.x = x; 2234 this.x = x;
2230 } 2235 }
2231 } 2236 }
2232 class Derived extends Base { 2237 class Derived extends Base {
2233 constructor(x) { 2238 constructor(x) {
2234 eval('super(...[x])'); 2239 let r = eval('super(...[x])');
2240 assertEquals(this, r);
2235 } 2241 }
2236 } 2242 }
2237 let d = new Derived(42); 2243 let d = new Derived(42);
2238 assertSame(42, d.x); 2244 assertSame(42, d.x);
2239 })(); 2245 })();
2240 2246
2241 2247
2242 (function TestSuperCallSpreadInArrow() { 2248 (function TestSuperCallSpreadInArrow() {
2243 'use strict'; 2249 'use strict';
2244 class Base { 2250 class Base {
2245 constructor(x) { 2251 constructor(x) {
2246 this.x = x; 2252 this.x = x;
2247 } 2253 }
2248 } 2254 }
2249 class Derived extends Base { 2255 class Derived extends Base {
2250 constructor(x) { 2256 constructor(x) {
2251 (() => super(...[x]))(); 2257 let r = (() => super(...[x]))();
2258 assertEquals(this, r);
2252 } 2259 }
2253 } 2260 }
2254 let d = new Derived(42); 2261 let d = new Derived(42);
2255 assertSame(42, d.x); 2262 assertSame(42, d.x);
2256 })(); 2263 })();
OLDNEW
« no previous file with comments | « src/x87/full-codegen-x87.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698