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

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

Issue 1532873004: [es6] enable destructuring rest parameters (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Update test262 expectations Created 4 years, 11 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/cctest/test-parsing.cc ('k') | test/test262/test262.status » ('j') | 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 (function testRestIndex() { 5 (function testRestIndex() {
6 assertEquals(5, (function(...args) { return args.length; })(1,2,3,4,5)); 6 assertEquals(5, (function(...args) { return args.length; })(1,2,3,4,5));
7 assertEquals(4, (function(a, ...args) { return args.length; })(1,2,3,4,5)); 7 assertEquals(4, (function(a, ...args) { return args.length; })(1,2,3,4,5));
8 assertEquals(3, (function(a, b, ...args) { return args.length; })(1,2,3,4,5)); 8 assertEquals(3, (function(a, b, ...args) { return args.length; })(1,2,3,4,5));
9 assertEquals(2, (function(a, b, c, ...args) { 9 assertEquals(2, (function(a, b, c, ...args) {
10 return args.length; })(1,2,3,4,5)); 10 return args.length; })(1,2,3,4,5));
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 function(){ eval("(class{foo(...rest) {'use strict';}});") }, SyntaxError); 210 function(){ eval("(class{foo(...rest) {'use strict';}});") }, SyntaxError);
211 211
212 assertThrows( 212 assertThrows(
213 function(){ eval("function(a, ...rest){'use strict';}") }, SyntaxError); 213 function(){ eval("function(a, ...rest){'use strict';}") }, SyntaxError);
214 assertThrows( 214 assertThrows(
215 function(){ eval("(a, ...rest) => {'use strict';}") }, SyntaxError); 215 function(){ eval("(a, ...rest) => {'use strict';}") }, SyntaxError);
216 assertThrows( 216 assertThrows(
217 function(){ eval("(class{foo(a, ...rest) {'use strict';}});") }, 217 function(){ eval("(class{foo(a, ...rest) {'use strict';}});") },
218 SyntaxError); 218 SyntaxError);
219 })(); 219 })();
220
221 (function TestRestArrayPattern() {
222 function f(...[a, b, c]) { return a + b + c; }
223 assertEquals(6, f(1, 2, 3));
224 assertEquals("123", f(1, "2", 3));
225 assertEquals(NaN, f(1));
226
227 var f2 = (...[a, b, c]) => a + b + c;
228 assertEquals(6, f2(1, 2, 3));
229 assertEquals("123", f2(1, "2", 3));
230 assertEquals(NaN, f2(1));
231 })();
232
233 (function TestRestObjectPattern() {
234 function f(...{length, 0: firstName, 1: lastName}) {
235 return `Hello ${lastName}, ${firstName}! Called with ${length} args!`;
236 }
237 assertEquals("Hello Ross, Bob! Called with 4 args!", f("Bob", "Ross", 0, 0));
238
239 var f2 = (...{length, 0: firstName, 1: lastName}) =>
240 `Hello ${lastName}, ${firstName}! Called with ${length} args!`;
241 assertEquals("Hello Ross, Bob! Called with 4 args!", f2("Bob", "Ross", 0, 0));
242 })();
OLDNEW
« no previous file with comments | « test/cctest/test-parsing.cc ('k') | test/test262/test262.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698