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

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

Issue 1167393005: [destructuring] Parse binding patterns in formal parameters. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: CR feedback + rebase Created 5 years, 6 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 | « src/preparser.cc ('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 6132d4109d2bc1c966962d9154649c8dfd57bc6d..675b48797952dbaf3e0afd23b933c61651ea1998 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -6380,11 +6380,17 @@ TEST(StrongModeFreeVariablesNotDeclared) {
TEST(DestructuringPositiveTests) {
i::FLAG_harmony_destructuring = true;
+ i::FLAG_harmony_arrow_functions = true;
i::FLAG_harmony_computed_property_names = true;
const char* context_data[][2] = {{"'use strict'; let ", " = {};"},
{"var ", " = {};"},
{"'use strict'; const ", " = {};"},
+ {"function f(", ") {}"},
+ {"function f(argument1, ", ") {}"},
+ {"var f = (", ") => {};"},
+ {"var f = ", " => {};"},
+ {"var f = (argument1,", ") => {};"},
{NULL, NULL}};
// clang-format off
@@ -6424,9 +6430,9 @@ TEST(DestructuringPositiveTests) {
"[a,,...rest]",
NULL};
// clang-format on
- static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals,
- kAllowHarmonyComputedPropertyNames,
- kAllowHarmonyDestructuring};
+ static const ParserFlag always_flags[] = {
+ kAllowHarmonyObjectLiterals, kAllowHarmonyComputedPropertyNames,
+ kAllowHarmonyArrowFunctions, kAllowHarmonyDestructuring};
RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags,
arraysize(always_flags));
}
@@ -6434,15 +6440,21 @@ TEST(DestructuringPositiveTests) {
TEST(DestructuringNegativeTests) {
i::FLAG_harmony_destructuring = true;
+ i::FLAG_harmony_arrow_functions = true;
i::FLAG_harmony_computed_property_names = true;
- static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals,
- kAllowHarmonyComputedPropertyNames,
- kAllowHarmonyDestructuring};
+ static const ParserFlag always_flags[] = {
+ kAllowHarmonyObjectLiterals, kAllowHarmonyComputedPropertyNames,
+ kAllowHarmonyArrowFunctions, kAllowHarmonyDestructuring};
{ // All modes.
const char* context_data[][2] = {{"'use strict'; let ", " = {};"},
{"var ", " = {};"},
{"'use strict'; const ", " = {};"},
+ {"function f(", ") {}"},
+ {"function f(argument1, ", ") {}"},
+ {"var f = (", ") => {};"},
+ {"var f = ", " => {};"},
+ {"var f = (argument1,", ") => {};"},
{NULL, NULL}};
// clang-format off
@@ -6475,7 +6487,6 @@ TEST(DestructuringNegativeTests) {
"a >>> a",
"function a() {}",
"a`bcd`",
- "x => x",
"this",
"null",
"true",
@@ -6483,7 +6494,6 @@ TEST(DestructuringNegativeTests) {
"1",
"'abc'",
"class {}",
- "() => x",
"{+2 : x}",
"{-2 : x}",
"var",
@@ -6509,13 +6519,36 @@ TEST(DestructuringNegativeTests) {
arraysize(always_flags));
}
- { // Strict mode.
+ { // All modes.
const char* context_data[][2] = {{"'use strict'; let ", " = {};"},
+ {"var ", " = {};"},
{"'use strict'; const ", " = {};"},
+ {"function f(", ") {}"},
+ {"function f(argument1, ", ") {}"},
+ {"var f = (", ") => {};"},
+ {"var f = (argument1,", ") => {};"},
{NULL, NULL}};
// clang-format off
const char* data[] = {
+ "x => x",
+ "() => x",
+ NULL};
+ // clang-format on
+ RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
+ arraysize(always_flags));
+ }
+
+ { // Strict mode.
+ const char* context_data[][2] = {
+ {"'use strict'; let ", " = {};"},
+ {"'use strict'; const ", " = {};"},
+ {"'use strict'; function f(", ") {}"},
+ {"'use strict'; function f(argument1, ", ") {}"},
+ {NULL, NULL}};
+
+ // clang-format off
+ const char* data[] = {
"[eval]",
"{ a : arguments }",
"[public]",
« no previous file with comments | « src/preparser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698