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

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: rebase + clang-format Created 5 years, 8 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 1f880c53ce4b285264679e073a8141bd8c9c27ad..33e2d3940708f4c10f46ffebf8ccd695c4908ff4 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -1380,7 +1380,8 @@ enum ParserFlag {
kAllowHarmonySloppy,
kAllowHarmonyUnicode,
kAllowHarmonyComputedPropertyNames,
- kAllowStrongMode
+ kAllowStrongMode,
+ kAllowHarmonySpreadCalls
};
@@ -1403,6 +1404,8 @@ void SetParserFlags(i::ParserBase<Traits>* parser,
parser->set_allow_harmony_classes(flags.Contains(kAllowHarmonyClasses));
parser->set_allow_harmony_rest_params(
flags.Contains(kAllowHarmonyRestParameters));
+ parser->set_allow_harmony_spreadcalls(
+ flags.Contains(kAllowHarmonySpreadCalls));
parser->set_allow_harmony_sloppy(flags.Contains(kAllowHarmonySloppy));
parser->set_allow_harmony_unicode(flags.Contains(kAllowHarmonyUnicode));
parser->set_allow_harmony_computed_property_names(
@@ -5104,6 +5107,52 @@ 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",
+ "0, 1, ...[2, 3, 4], 5, 6, 7, ...'89'",
+ "0, 1, ...[2, 3, 4], 5, 6, 7, ...'89', 10",
+ "...[0, 1, 2], 3, 4, 5, 6, ...'7', 8, 9",
+ "...[0, 1, 2], 3, 4, 5, 6, ...'7', 8, 9, ...[10]", 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