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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/test-parsing.cc ('k') | test/test262/test262.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/rest-params.js
diff --git a/test/mjsunit/es6/rest-params.js b/test/mjsunit/es6/rest-params.js
index 104add8c385ced97159b006a335895f2bd21396a..9afe9b409e62af33f1ab2545c2dbffa81a149c5d 100644
--- a/test/mjsunit/es6/rest-params.js
+++ b/test/mjsunit/es6/rest-params.js
@@ -217,3 +217,26 @@ var O = {
function(){ eval("(class{foo(a, ...rest) {'use strict';}});") },
SyntaxError);
})();
+
+(function TestRestArrayPattern() {
+ function f(...[a, b, c]) { return a + b + c; }
+ assertEquals(6, f(1, 2, 3));
+ assertEquals("123", f(1, "2", 3));
+ assertEquals(NaN, f(1));
+
+ var f2 = (...[a, b, c]) => a + b + c;
+ assertEquals(6, f2(1, 2, 3));
+ assertEquals("123", f2(1, "2", 3));
+ assertEquals(NaN, f2(1));
+})();
+
+(function TestRestObjectPattern() {
+ function f(...{length, 0: firstName, 1: lastName}) {
+ return `Hello ${lastName}, ${firstName}! Called with ${length} args!`;
+ }
+ assertEquals("Hello Ross, Bob! Called with 4 args!", f("Bob", "Ross", 0, 0));
+
+ var f2 = (...{length, 0: firstName, 1: lastName}) =>
+ `Hello ${lastName}, ${firstName}! Called with ${length} args!`;
+ assertEquals("Hello Ross, Bob! Called with 4 args!", f2("Bob", "Ross", 0, 0));
+})();
« 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