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

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

Issue 1808373003: Implement ES2015 labelled function declaration restrictions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix style Created 4 years, 9 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/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 7d318672a1b15ff1368e1164cf74146b9efb14ce..98ef9e4d2205ae750a1c57be29f14cd3e821ed58 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -7217,10 +7217,13 @@ TEST(FunctionDeclarationError) {
{"(function() { {", "} })()"},
{ NULL, NULL }
};
+ // Invalid in all contexts
const char* error_data[] = {
"try function foo() {} catch (e) {}",
NULL
};
+ // Valid in sloppy mode only, and only when the
+ // --harmony-restrictive-declarations flag is off
const char* unrestricted_data[] = {
"do function foo() {} while (0);",
"for (;false;) function foo() {}",
@@ -7232,16 +7235,28 @@ TEST(FunctionDeclarationError) {
"for (x in {}) function f() { };",
"var x; for (x in {}) function foo() {}",
"with ({}) function f() { };",
+ "do label: function foo() {} while (0);",
+ "for (;false;) label: function foo() {}",
+ "for (var i = 0; i < 1; i++) label: function f() { };",
+ "for (var x in {a: 1}) label: function f() { };",
+ "for (var x in {}) label: function f() { };",
+ "for (var x in {}) label: function foo() {}",
+ "for (x in {a: 1}) label: function f() { };",
+ "for (x in {}) label: function f() { };",
+ "var x; for (x in {}) label: function foo() {}",
+ "with ({}) label: function f() { };",
+ "if (true) label: function f() {}",
+ "if (true) {} else label: function f() {}",
NULL
};
+ // Valid only in sloppy mode, with or without
+ // --harmony-restrictive-declarations
const char* sloppy_data[] = {
"if (true) function foo() {}",
"if (false) {} else function f() { };",
"label: function f() { }",
"label: if (true) function f() { }",
"label: if (true) {} else function f() { }",
- "if (true) label: function f() {}",
- "if (true) {} else label: function f() {}",
NULL
};
// clang-format on
@@ -7249,6 +7264,7 @@ TEST(FunctionDeclarationError) {
static const ParserFlag restrictive_flags[] = {
kAllowHarmonyRestrictiveDeclarations};
+ // Nothing parses in strict mode without a SyntaxError
RunParserSyncTest(strict_context, error_data, kError);
RunParserSyncTest(strict_context, error_data, kError, NULL, 0,
restrictive_flags, arraysize(restrictive_flags));
@@ -7259,6 +7275,7 @@ TEST(FunctionDeclarationError) {
RunParserSyncTest(strict_context, sloppy_data, kError, NULL, 0,
restrictive_flags, arraysize(restrictive_flags));
+ // In sloppy mode, some things are successful, depending on the flag
RunParserSyncTest(sloppy_context, error_data, kError);
RunParserSyncTest(sloppy_context, error_data, kError, NULL, 0,
restrictive_flags, arraysize(restrictive_flags));
« no previous file with comments | « src/parsing/preparser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698