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

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: Remove --harmony-spread flag 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 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 9d47ec1a225e1750d7405181301140ab5b99c5d5..7ee432514bd744c875da2cb53b79a8a05ef217df 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -1381,7 +1381,8 @@ enum ParserFlag {
kAllowHarmonySloppy,
kAllowHarmonyUnicode,
kAllowHarmonyComputedPropertyNames,
- kAllowStrongMode
+ kAllowStrongMode,
+ kAllowHarmonySpreadCalls
};
@@ -1406,6 +1407,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(
@@ -4935,6 +4938,64 @@ 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