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

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

Issue 1219853004: [es6] Initial support for let/const bindings in sloppy mode (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Updated tests and comments Created 5 years, 5 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 cbb79b16da9cc757f385978cb90193f14614163d..a28ba2a0759954c311873132275a6b1ec7e23429 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -6766,7 +6766,7 @@ TEST(NewTarget) {
}
-TEST(LegacyConst) {
+TEST(ConstLegacy) {
// clang-format off
const char* context_data[][2] = {
{"", ""},
@@ -6784,9 +6784,57 @@ TEST(LegacyConst) {
};
// clang-format on
- static const ParserFlag always_flags[] = {kNoLegacyConst};
+ static const ParserFlag always_flags[] = {kNoLegacyConst};
RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
arraysize(always_flags));
RunParserSyncTest(context_data, data, kSuccess);
}
+
+
+TEST(ConstSloppy) {
+ // clang-format off
+ const char* context_data[][2] = {
+ {"", ""},
+ {"{", "}"},
+ {NULL, NULL}
+ };
+
+ const char* data[] = {
+ "const x = 1",
+ "for (const x = 1; x < 1; x++) {}",
+ "for (const x in {}) {}",
+ "for (const x of []) {}",
+ NULL
+ };
+ // clang-format on
+ static const ParserFlag always_flags[] = {kAllowHarmonySloppy,
+ kNoLegacyConst};
+ RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags,
+ arraysize(always_flags));
+}
+
+
+TEST(LetSloppy) {
+ // clang-format off
+ const char* context_data[][2] = {
+ {"", ""},
+ {"'use strict';", ""},
+ {"{", "}"},
+ {NULL, NULL}
+ };
+
+ const char* data[] = {
+ "let x",
+ "let x = 1",
+ "for (let x = 1; x < 1; x++) {}",
+ "for (let x in {}) {}",
+ "for (let x of []) {}",
+ NULL
+ };
+ // clang-format on
+
+ static const ParserFlag always_flags[] = {kAllowHarmonySloppy};
+ RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags,
+ arraysize(always_flags));
+}

Powered by Google App Engine
This is Rietveld 408576698