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

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

Issue 1941823003: Properly disallow 'yield' in class expressions and arrow parameters (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Better error message for yield in parameter Created 4 years, 8 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 a28c235c5e3f036049c8cdf32d6ba6fedcdcacd1..7f297b3d67a58b260ce1359c0722b398c5cfce96 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -2332,6 +2332,10 @@ TEST(NoErrorsGenerator) {
"(yield) \n ? yield : yield",
// If there is a newline before the next token, we don't look for RHS.
"yield\nfor (;;) {}",
+ "x = class extends (yield) {}",
+ "x = class extends f(yield) {}",
+ "x = class extends (null, yield) { }",
+ "x = class extends (a ? null : yield) { }",
NULL
};
// clang-format on
@@ -2396,6 +2400,7 @@ TEST(ErrorsYieldGenerator) {
"for (yield 'x' of {});",
"for (yield 'x' in {} in {});",
"for (yield 'x' in {} of {});",
+ "class C extends yield { }",
NULL
};
// clang-format on
@@ -6730,6 +6735,9 @@ TEST(DefaultParametersYieldInInitializers) {
const char* generator_context_data[][2] = {
{"'use strict'; (function *g(", ") { });"},
{"(function *g(", ") { });"},
+ // Arrow function within generator has the same rules.
+ {"'use strict'; (function *g() { (", ") => {} });"},
+ {"(function *g() { (", ") => {} });"},
{NULL, NULL}
};
@@ -6760,6 +6768,17 @@ TEST(DefaultParametersYieldInInitializers) {
NULL
};
+ // Because classes are always in strict mode, these are always errors.
+ const char* always_error_param_data[] = {
+ "x = class extends (yield) { }",
+ "x = class extends f(yield) { }",
+ "x = class extends (null, yield) { }",
+ "x = class extends (a ? null : yield) { }",
+ "[x] = [class extends (a ? null : yield) { }]",
+ "[x = class extends (a ? null : yield) { }]",
+ "[x = class extends (a ? null : yield) { }] = [null]",
+ NULL
+ };
// clang-format on
RunParserSyncTest(sloppy_function_context_data, parameter_data, kSuccess);
@@ -6769,9 +6788,9 @@ TEST(DefaultParametersYieldInInitializers) {
RunParserSyncTest(strict_arrow_context_data, parameter_data, kError);
RunParserSyncTest(generator_context_data, parameter_data, kError);
+ RunParserSyncTest(generator_context_data, always_error_param_data, kError);
}
-
TEST(SpreadArray) {
const char* context_data[][2] = {
{"'use strict';", ""}, {"", ""}, {NULL, NULL}};

Powered by Google App Engine
This is Rietveld 408576698