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

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

Issue 1320673007: Disallow yield in default parameter initializers (Closed) Base URL: https://chromium.googlesource.com/v8/v8@master
Patch Set: Rebase Created 5 years, 4 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.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 1ea550caab1dc65b1fe0f320531bb250748c604d..4f73c9ffdfca05d167732df183fb460997a4d014 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -6752,6 +6752,71 @@ TEST(DestructuringDisallowPatternsInRestParams) {
}
+TEST(DefaultParametersYieldInInitializers) {
+ // clang-format off
+ const char* sloppy_function_context_data[][2] = {
+ {"(function f(", ") { });"},
+ // TODO(wingo): Add arrow functions.
+ {NULL, NULL}
+ };
+
+ const char* strict_function_context_data[][2] = {
+ {"'use strong'; (function f(", ") { });"},
+ {"'use strict'; (function f(", ") { });"},
+ // TODO(wingo,conradw): These should also signal early errors.
+ // {"(function f(", ") {'use strong'; });"},
+ // {"(function f(", ") {'use strict'; });"},
+ // TODO(wingo): Add arrow functions.
+ {NULL, NULL}
+ };
+
+ const char* generator_context_data[][2] = {
+ {"'use strong'; (function *g(", ") { });"},
+ {"'use strict'; (function *g(", ") { });"},
+ // TODO(wingo,conradw): These should also signal early errors.
+ // {"(function *g(", ") {'use strong'; });"},
+ // {"(function *g(", ") {'use strict'; });"},
+ {"(function *g(", ") { });"},
+ {NULL, NULL}
+ };
+
+ const char* formal_parameter_data[] = {
+ "x=yield",
+ "x, y=yield",
+ "{x=yield}",
+ "[x=yield]",
+ "{x}=yield",
+ "[x]=yield",
+
+ "x=(yield)",
+ "x, y=(yield)",
+ "{x=(yield)}",
+ "[x=(yield)]",
+ "{x}=(yield)",
+ "[x]=(yield)",
+
+ "x=f(yield)",
+ "x, y=f(yield)",
+ "{x=f(yield)}",
+ "[x=f(yield)]",
+ "{x}=f(yield)",
+ "[x]=f(yield)",
+ NULL
+ };
+
+ // clang-format on
+ static const ParserFlag always_flags[] = {
+ kAllowHarmonyDestructuring, kAllowHarmonyDefaultParameters,
+ kAllowHarmonyArrowFunctions, kAllowStrongMode};
+ RunParserSyncTest(sloppy_function_context_data, formal_parameter_data,
+ kSuccess, NULL, 0, always_flags, arraysize(always_flags));
+ RunParserSyncTest(strict_function_context_data, formal_parameter_data, kError,
+ NULL, 0, always_flags, arraysize(always_flags));
+ RunParserSyncTest(generator_context_data, formal_parameter_data, kError, NULL,
+ 0, always_flags, arraysize(always_flags));
+}
+
+
TEST(SpreadArray) {
i::FLAG_harmony_spread_arrays = true;
« no previous file with comments | « src/preparser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698