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

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

Issue 885243002: Implement parsing of ES6 Rest Parameters (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« src/scanner.cc ('K') | « src/token.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-parsing.cc
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index f15224f8da0d7d444f75cf04fc25f56f4d11e3ef..f101fd42d1c538fd9a4abf05bbd6940ea8ddafd8 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -1356,6 +1356,7 @@ enum ParserFlag {
kAllowHarmonyArrowFunctions,
kAllowHarmonyClasses,
kAllowHarmonyObjectLiterals,
+ kAllowHarmonyRestParameters,
kAllowHarmonyTemplates,
kAllowHarmonySloppy,
kAllowHarmonyUnicode,
@@ -1384,6 +1385,8 @@ void SetParserFlags(i::ParserBase<Traits>* parser,
flags.Contains(kAllowHarmonyArrowFunctions));
parser->set_allow_harmony_classes(flags.Contains(kAllowHarmonyClasses));
parser->set_allow_harmony_templates(flags.Contains(kAllowHarmonyTemplates));
+ parser->set_allow_harmony_rest_params(
+ flags.Contains(kAllowHarmonyRestParameters));
parser->set_allow_harmony_sloppy(flags.Contains(kAllowHarmonySloppy));
parser->set_allow_harmony_unicode(flags.Contains(kAllowHarmonyUnicode));
parser->set_allow_harmony_computed_property_names(
@@ -4568,6 +4571,66 @@ TEST(TemplateLiteralsIllegalTokens) {
}
+TEST(ParseRestParameters) {
+ const char* context_data[][2] = {{"'use strict';(function(",
+ "){ return args;})(1, [], /regexp/, 'str',"
+ "function(){});"},
+ {"(function(", "){ return args;})(1, [],"
+ "/regexp/, 'str', function(){});"},
+ {NULL, NULL}};
+
+ const char* data[] = {
+ "...args",
+ "a, ...args",
+ "... args",
+ "a, ... args",
+ "...\targs",
+ "a, ...\targs",
+ "...\r\nargs",
+ "a, ...\r\nargs",
+ "...\rargs",
+ "a, ...\rargs",
+ "...\t\n\t\t\n args",
+ "a, ... \n \n args",
+ NULL};
+ static const ParserFlag always_flags[] = {kAllowHarmonyRestParameters};
+ RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags,
+ arraysize(always_flags));
+}
+
+
+TEST(ParseRestParametersErrors) {
+ const char* context_data[][2] = {{"'use strict';(function(",
+ "){ return args;}(1, [], /regexp/, 'str',"
+ "function(){});"},
+ {"(function(", "){ return args;}(1, [],"
+ "/regexp/, 'str', function(){});"},
+ {NULL, NULL}};
+
+ const char* data[] = {
+ "...args, b",
+ "a, ...args, b",
+ "...args, b",
+ "a, ...args, b",
+ "...args,\tb",
+ "a,...args\t,b",
+ "...args\r\n, b",
+ "a, ... args,\r\nb",
+ "...args\r,b",
+ "a, ... args,\rb",
+ "...args\t\n\t\t\n, b",
+ "a, ... args, \n \n b",
+ "a, a, ...args",
+ "a,\ta, ...args",
+ "a,\ra, ...args",
+ "a,\na, ...args",
+ NULL};
+ static const ParserFlag always_flags[] = {kAllowHarmonyRestParameters};
+ RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
+ arraysize(always_flags));
+}
+
+
TEST(LexicalScopingSloppyMode) {
const char* context_data[][2] = {
{"", ""},
« src/scanner.cc ('K') | « src/token.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698