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

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

Issue 1244423003: [es6] Fix function context check for super and new.target (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Comment; added test for super calls 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 | « test/mjsunit/harmony/new-target.js ('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 --harmony-destructuring
7 // Flags: --harmony-rest-parameters --harmony-sloppy
7 8
8 (function TestSuperNamedLoads() { 9 (function TestSuperNamedLoads() {
9 function Base() { } 10 function Base() { }
10 function fBase() { } 11 function fBase() { }
11 Base.prototype = { 12 Base.prototype = {
12 f() { 13 f() {
13 return "Base " + this.toString(); 14 return "Base " + this.toString();
14 }, 15 },
15 x: 15, 16 x: 15,
16 toString() { 17 toString() {
(...skipping 2098 matching lines...) Expand 10 before | Expand all | Expand 10 after
2115 assertSame(super.x, (() => super.x)()); 2116 assertSame(super.x, (() => super.x)());
2116 assertSame(super.m(), (() => super.m())()); 2117 assertSame(super.m(), (() => super.m())());
2117 return (() => super.m())(); 2118 return (() => super.m())();
2118 } 2119 }
2119 } 2120 }
2120 let d = new Derived(); 2121 let d = new Derived();
2121 assertSame(1, d.arrow()); 2122 assertSame(1, d.arrow());
2122 })(); 2123 })();
2123 2124
2124 2125
2126 (function TestSuperInOtherScopes() {
2127 var p = {x: 99};
2128 var o0 = {__proto__: p, f() { return eval("'use strict'; super.x") }};
2129 assertEquals(p.x, o0.f());
2130 var o1 = {__proto__: p, f() { with ({}) return super.x }};
2131 assertEquals(p.x, o1.f());
2132 var o2 = {__proto__: p, f({a}) { return super.x }};
2133 assertEquals(p.x, o2.f({}));
2134 var o3 = {__proto__: p, f(...a) { return super.x }};
2135 assertEquals(p.x, o3.f());
2136 var o4 = {__proto__: p, f() { 'use strict'; { let x; return super.x } }};
2137 assertEquals(p.x, o4.f());
2138 })();
2139
2140
2141 (function TestSuperCallInOtherScopes() {
2142 class C {constructor() { this.x = 99 }}
2143 class D0 extends C {constructor() { eval("'use strict'; super()") }}
2144 assertEquals(99, (new D0).x);
2145 class D2 extends C {constructor({a}) { super() }}
2146 assertEquals(99, (new D2({})).x);
2147 class D3 extends C {constructor(...a) { super() }}
2148 assertEquals(99, (new D3()).x);
2149 class D4 extends C {constructor() { { let x; super() } }}
2150 assertEquals(99, (new D4).x);
2151 })();
2152
2153
2125 (function TestSuperCallInEval() { 2154 (function TestSuperCallInEval() {
2126 'use strict'; 2155 'use strict';
2127 class Base { 2156 class Base {
2128 constructor(x) { 2157 constructor(x) {
2129 this.x = x; 2158 this.x = x;
2130 } 2159 }
2131 } 2160 }
2132 class Derived extends Base { 2161 class Derived extends Base {
2133 constructor(x) { 2162 constructor(x) {
2134 let r = eval('super(x)'); 2163 let r = eval('super(x)');
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
2254 } 2283 }
2255 class Derived extends Base { 2284 class Derived extends Base {
2256 constructor(x) { 2285 constructor(x) {
2257 let r = (() => super(...[x]))(); 2286 let r = (() => super(...[x]))();
2258 assertEquals(this, r); 2287 assertEquals(this, r);
2259 } 2288 }
2260 } 2289 }
2261 let d = new Derived(42); 2290 let d = new Derived(42);
2262 assertSame(42, d.x); 2291 assertSame(42, d.x);
2263 })(); 2292 })();
OLDNEW
« no previous file with comments | « test/mjsunit/harmony/new-target.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698