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

Side by Side Diff: test/mjsunit/harmony/regress/regress-4395.js

Issue 1405313002: [es6] Fix scoping for default parameters in arrow functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix class literal handling Created 5 years, 2 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/scopes.cc ('k') | tools/gyp/v8.gyp » ('j') | 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 2015 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-destructuring --harmony-default-parameters
6
7 (function testExpressionTypes() {
8 "use strict";
9 ((x, y = x) => assertEquals(42, y))(42);
10
11 ((x, y = (x)) => assertEquals(42, y))(42);
12 ((x, y = `${x}`) => assertEquals("42", y))(42);
13 ((x, y = x = x + 1) => assertEquals(43, y))(42);
14 ((x, y = x()) => assertEquals(42, y))(() => 42);
15 ((x, y = new x()) => assertEquals(42, y.z))(function() { this.z = 42 });
16 ((x, y = -x) => assertEquals(-42, y))(42);
17 ((x, y = ++x) => assertEquals(43, y))(42);
18 ((x, y = x === 42) => assertTrue(y))(42);
19 ((x, y = (x == 42 ? x : 0)) => assertEquals(42, y))(42);
20
21 ((x, y = function() { return x }) => assertEquals(42, y()))(42);
22 ((x, y = () => x) => assertEquals(42, y()))(42);
23
24 // Literals
25 ((x, y = {z: x}) => assertEquals(42, y.z))(42);
26 ((x, y = {[x]: x}) => assertEquals(42, y[42]))(42);
27 ((x, y = [x]) => assertEquals(42, y[0]))(42);
28 ((x, y = [...x]) => assertEquals(42, y[0]))([42]);
29
30 ((x, y = class {
31 static [x]() { return x }
32 }) => assertEquals(42, y[42]()))(42);
33 ((x, y = (new class {
34 z() { return x }
35 })) => assertEquals(42, y.z()))(42);
36
37 ((x, y = (new class Y {
38 static [x]() { return x }
39 z() { return Y[42]() }
40 })) => assertEquals(42, y.z()))(42);
41
42 ((x, y = (new class {
43 constructor() { this.z = x }
44 })) => assertEquals(42, y.z))(42);
45 ((x, y = (new class Y {
46 constructor() { this.z = x }
47 })) => assertEquals(42, y.z))(42);
48
49 ((x, y = (new class extends x {
50 })) => assertEquals(42, y.z()))(class { z() { return 42 } });
51
52 // Defaults inside destructuring
53 ((x, {y = x}) => assertEquals(42, y))(42, {});
54 ((x, [y = x]) => assertEquals(42, y))(42, []);
55 })();
56
57 (function testMultiScopeCapture() {
58 "use strict";
59 var x = 1;
60 {
61 let y = 2;
62 ((x, y, a = x, b = y) => {
63 assertEquals(3, x);
64 assertEquals(3, a);
65 assertEquals(4, y);
66 assertEquals(4, b);
67 })(3, 4);
68 }
69 })();
OLDNEW
« no previous file with comments | « src/scopes.cc ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698