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

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

Issue 1218803006: Add a flag for legacy const semantics (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add message tests 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
« no previous file with comments | « src/preparser.cc ('k') | test/message/no-legacy-const.js » ('j') | 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 88dadcb1bf8ba35db6d0d986065e2f52ca370350..cbb79b16da9cc757f385978cb90193f14614163d 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -1436,7 +1436,8 @@ enum ParserFlag {
kAllowHarmonyDestructuring,
kAllowHarmonySpreadArrays,
kAllowHarmonyNewTarget,
- kAllowStrongMode
+ kAllowStrongMode,
+ kNoLegacyConst
};
@@ -1468,6 +1469,7 @@ void SetParserFlags(i::ParserBase<Traits>* parser,
flags.Contains(kAllowHarmonySpreadArrays));
parser->set_allow_harmony_new_target(flags.Contains(kAllowHarmonyNewTarget));
parser->set_allow_strong_mode(flags.Contains(kAllowStrongMode));
+ parser->set_allow_legacy_const(!flags.Contains(kNoLegacyConst));
}
@@ -6762,3 +6764,29 @@ TEST(NewTarget) {
RunParserSyncTest(bad_context_data, data, kError, NULL, 0, always_flags,
arraysize(always_flags));
}
+
+
+TEST(LegacyConst) {
+ // clang-format off
+ const char* context_data[][2] = {
+ {"", ""},
+ {"{", "}"},
+ {NULL, NULL}
+ };
+
+ const char* data[] = {
+ "const x",
+ "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[] = {kNoLegacyConst};
+
+ RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
+ arraysize(always_flags));
+ RunParserSyncTest(context_data, data, kSuccess);
+}
« no previous file with comments | « src/preparser.cc ('k') | test/message/no-legacy-const.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698