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

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

Issue 1062263002: [parser] report better errors for multiple ForBindings in ForIn/Of loops (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« src/preparser.cc ('K') | « 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 a086c3ec617142db00252cb462ba2a06506ac4e3..c735c03470cbe7b5cafceefde6998424c35e5613 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -4628,6 +4628,67 @@ TEST(ConstParsingInForInError) {
}
+TEST(InitializedDeclarationsInStrictForInError) {
+ const char* context_data[][2] = {{"'use strict';", ""},
+ {"function foo(){ 'use strict';", "}"},
+ {NULL, NULL}};
+
+ const char* data[] = {
+ "for (var i = 1 in {}) {}",
+ "for (var i = void 0 in [1, 2, 3]) {}",
+ "for (let i = 1 in {}) {}",
+ "for (let i = void 0 in [1, 2, 3]) {}",
+ "for (const i = 1 in {}) {}",
+ "for (const i = void 0 in [1, 2, 3]) {}",
+ NULL};
+ RunParserSyncTest(context_data, data, kError, nullptr, 0, nullptr, 0);
marja 2015/04/08 10:05:47 You don't need the params after kError.
+}
+
+
+TEST(InitializedDeclarationsInStrictForOfError) {
+ const char* context_data[][2] = {{"'use strict';", ""},
+ {"function foo(){ 'use strict';", "}"},
+ {NULL, NULL}};
+
+ const char* data[] = {
+ "for (var i = 1 of {}) {}",
+ "for (var i = void 0 of [1, 2, 3]) {}",
+ "for (let i = 1 of {}) {}",
+ "for (let i = void 0 of [1, 2, 3]) {}",
+ "for (const i = 1 of {}) {}",
+ "for (const i = void 0 of [1, 2, 3]) {}",
+ NULL};
+ RunParserSyncTest(context_data, data, kError, nullptr, 0, nullptr, 0);
+}
+
+
+TEST(InitializedDeclarationsInSloppyForInError) {
+ const char* context_data[][2] = {{"", ""},
+ {"function foo(){", "}"},
+ {NULL, NULL}};
+
+ const char* data[] = {
+ "for (var i = 1 in {}) {}",
+ "for (var i = void 0 in [1, 2, 3]) {}",
+ NULL};
+ // TODO(caitp): This should be an error in sloppy mode.
+ RunParserSyncTest(context_data, data, kSuccess, nullptr, 0, nullptr, 0);
+}
+
+
+TEST(InitializedDeclarationsInSloppyForOfError) {
+ const char* context_data[][2] = {{"", ""},
+ {"function foo(){", "}"},
+ {NULL, NULL}};
+
+ const char* data[] = {
+ "for (var i = 1 of {}) {}",
+ "for (var i = void 0 of [1, 2, 3]) {}",
+ NULL};
+ RunParserSyncTest(context_data, data, kError, nullptr, 0, nullptr, 0);
+}
+
+
marja 2015/04/08 10:05:47 Hmm, none of the added tests exercises the code pa
caitp (gmail) 2015/04/08 12:44:36 done
TEST(InvalidUnicodeEscapes) {
const char* context_data[][2] = {{"", ""},
{"'use strict';", ""},
« src/preparser.cc ('K') | « src/preparser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698