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

Unified Diff: test/cctest/test-parsing.cc

Issue 938443002: [es6] implement spread calls (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add construct support, clean out some gunk Created 5 years, 10 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
Index: test/cctest/test-parsing.cc
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index 7a624cb0bf38f99a55ade2350f72af62986ed960..935e273ca10220dd118f5d784894badb315b06b2 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -1388,7 +1388,8 @@ enum ParserFlag {
kAllowHarmonySloppy,
kAllowHarmonyUnicode,
kAllowHarmonyComputedPropertyNames,
- kAllowStrongMode
+ kAllowStrongMode,
+ kAllowHarmonySpreadCalls
};
@@ -4982,6 +4983,60 @@ TEST(RestParametersDuplicateEvalArguments) {
}
+TEST(SpreadCall) {
+ const char* context_data[][2] = {{"function fn() { 'use strict';} fn(", ");"},
+ {"function fn() {} fn(", ");"},
+ {NULL, NULL}};
+
+ const char* data[] = {
+ "...([1, 2, 3])",
+ "...'123', ...'456'",
+ "...new Set([1, 2, 3]), 4",
+ "1, ...[2, 3], 4",
+ "...Array(...[1,2,3,4])",
+ "...NaN",
+ NULL};
+
+ static const ParserFlag always_flags[] = {kAllowHarmonySpreadCalls};
+
+ RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags,
+ arraysize(always_flags));
+}
+
+
+TEST(SpreadCallErrors) {
+ const char* context_data[][2] = {{"function fn() { 'use strict';} fn(", ");"},
+ {"function fn() {} fn(", ");"},
+ {NULL, NULL}};
+
+ const char* data[] = {
+ "(...[1, 2, 3])",
+ "......[1,2,3]",
+ NULL};
+
+ static const ParserFlag always_flags[] = {kAllowHarmonySpreadCalls};
+
+ RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
+ arraysize(always_flags));
+}
+
+
+TEST(BadRestSpread) {
+ const char* context_data[][2] = {{"function fn() { 'use strict';", "} fn();"},
+ {"function fn() { ", "} fn();" },
+ {NULL, NULL}};
+ const char* data[] = {
+ "return ...[1,2,3];",
+ "var ...x = [1,2,3];",
+ "var [...x,] = [1,2,3];",
+ "var [...x, y] = [1,2,3];",
+ "var {...x} = [1,2,3];",
+ "var { x } = {x: ...[1,2,3]}",
+ NULL};
+ RunParserSyncTest(context_data, data, kError, NULL, 0, NULL, 0);
+}
+
+
TEST(LexicalScopingSloppyMode) {
const char* context_data[][2] = {
{"", ""},

Powered by Google App Engine
This is Rietveld 408576698