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

Side by Side Diff: test/mjsunit/harmony/rest-params.js

Issue 997823003: [es6] support rest parameters in arrow functions (alternative) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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
« src/preparser.h ('K') | « test/cctest/test-parsing.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-rest-parameters 5 // Flags: --harmony-rest-parameters --harmony-arrow-functions
6 6
7 (function testRestIndex() { 7 (function testRestIndex() {
8 assertEquals(5, (function(...args) { return args.length; })(1,2,3,4,5)); 8 assertEquals(5, (function(...args) { return args.length; })(1,2,3,4,5));
9 assertEquals(4, (function(a, ...args) { return args.length; })(1,2,3,4,5)); 9 assertEquals(4, (function(a, ...args) { return args.length; })(1,2,3,4,5));
10 assertEquals(3, (function(a, b, ...args) { return args.length; })(1,2,3,4,5)); 10 assertEquals(3, (function(a, b, ...args) { return args.length; })(1,2,3,4,5));
11 assertEquals(2, (function(a, b, c, ...args) { 11 assertEquals(2, (function(a, b, c, ...args) {
12 return args.length; })(1,2,3,4,5)); 12 return args.length; })(1,2,3,4,5));
13 assertEquals(1, (function(a, b, c, d, ...args) { 13 assertEquals(1, (function(a, b, c, d, ...args) {
14 return args.length; })(1,2,3,4,5)); 14 return args.length; })(1,2,3,4,5));
15 assertEquals(0, (function(a, b, c, d, e, ...args) { 15 assertEquals(0, (function(a, b, c, d, e, ...args) {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 function sloppyF(a, ...rest) { 159 function sloppyF(a, ...rest) {
160 arguments[0] = 1; 160 arguments[0] = 1;
161 assertEquals(3, a); 161 assertEquals(3, a);
162 arguments[1] = 2; 162 arguments[1] = 2;
163 assertArrayEquals([4, 5], rest); 163 assertArrayEquals([4, 5], rest);
164 } 164 }
165 sloppyF(3, 4, 5); 165 sloppyF(3, 4, 5);
166 })(); 166 })();
167 167
168 168
169 /* TODO(caitp): support arrow functions (blocked on spread operator support)
170 (function testRestParamsArrowFunctions() { 169 (function testRestParamsArrowFunctions() {
171 "use strict"; 170 "use strict";
172 171
173 var fn = (a, b, ...c) => c; 172 var fn = (a, b, ...c) => c;
174 assertEquals([], fn()); 173 assertEquals([], fn());
175 assertEquals([], fn(1, 2)); 174 assertEquals([], fn(1, 2));
176 assertEquals([3], fn(1, 2, 3)); 175 assertEquals([3], fn(1, 2, 3));
177 assertEquals([3, 4], fn(1, 2, 3, 4)); 176 assertEquals([3, 4], fn(1, 2, 3, 4));
178 assertEquals([3, 4, 5], fn(1, 2, 3, 4, 5)); 177 assertEquals([3, 4, 5], fn(1, 2, 3, 4, 5));
179 assertThrows("var x = ...y => y;", SyntaxError); 178 assertThrows("var x = ...y => y;", SyntaxError);
180 assertEquals([], ((...args) => args)()); 179 assertEquals([], ((...args) => args)());
181 assertEquals([1,2,3], ((...args) => args)(1,2,3)); 180 assertEquals([1,2,3], ((...args) => args)(1,2,3));
182 })();*/ 181 })();
OLDNEW
« src/preparser.h ('K') | « test/cctest/test-parsing.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698