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

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

Issue 1632303002: Treat yield expressions as an AssignmentPattern error (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Added test Created 4 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
« no previous file with comments | « src/parsing/parser-base.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 03da6fd12415964e9242bca45978f73c7437fdd5..bc12153729c622cf8ad031f2ae486a679949368a 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -2308,6 +2308,7 @@ TEST(ErrorsYieldSloppy) {
TEST(NoErrorsGenerator) {
+ // clang-format off
const char* context_data[][2] = {
{ "function * gen() {", "}" },
{ "(function * gen() {", "})" },
@@ -2345,6 +2346,8 @@ TEST(NoErrorsGenerator) {
// Yield is still a valid key in object literals.
"({ yield: 1 })",
"({ get yield() { } })",
+ // And in assignment pattern computed properties
+ "({ [yield]: x } = { })",
// Yield without RHS.
"yield;",
"yield",
@@ -2362,12 +2365,17 @@ TEST(NoErrorsGenerator) {
"yield\nfor (;;) {}",
NULL
};
+ // clang-format on
- RunParserSyncTest(context_data, statement_data, kSuccess);
+ static const ParserFlag always_flags[] = {
+ kAllowHarmonyDestructuringAssignment};
+ RunParserSyncTest(context_data, statement_data, kSuccess, nullptr, 0,
+ always_flags, arraysize(always_flags));
}
TEST(ErrorsYieldGenerator) {
+ // clang-format off
const char* context_data[][2] = {
{ "function * gen() {", "}" },
{ "\"use strict\"; function * gen() {", "}" },
@@ -2408,8 +2416,19 @@ TEST(ErrorsYieldGenerator) {
"yield\n{yield: 42}",
"yield /* comment */\n {yield: 42}",
"yield //comment\n {yield: 42}",
+ // Destructuring binding and assignment are both disallowed
+ "var [yield] = [42];",
+ "var {foo: yield} = {a: 42};",
+ "[yield] = [42];",
+ "({a: yield} = {a: 42});",
+ // Also disallow full yield expressions on LHS
+ "var [yield 24] = [42];",
+ "var {foo: yield 24} = {a: 42};",
+ "[yield 24] = [42];",
+ "({a: yield 24} = {a: 42});",
NULL
};
+ // clang-format on
RunParserSyncTest(context_data, statement_data, kError);
}
« no previous file with comments | « src/parsing/parser-base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698