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

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

Issue 1371263003: Prohibit let in lexical bindings (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: remove messages.js test Created 5 years, 2 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/let-lexical-name-prohibited.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 fd447a835db9fe5d8d31a6b121bad496fd396567..dd73a43c9b9bba8e7485c1472d252e2c2bd0186d 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -7165,25 +7165,66 @@ TEST(LetSloppyOnly) {
const char* context_data[][2] = {
{"", ""},
{"{", "}"},
+ {"(function() {", "})()"},
{NULL, NULL}
};
const char* data[] = {
- "let let",
"let",
- "let let = 1",
"let = 1",
- "for (let let = 1; let < 1; let++) {}",
"for (let = 1; let < 1; let++) {}",
- "for (let let in {}) {}",
- "for (let let of []) {}",
"for (let in {}) {}",
+ "for (var let = 1; let < 1; let++) {}",
+ "for (var let in {}) {}",
+ "for (var [let] = 1; let < 1; let++) {}",
+ "for (var [let] in {}) {}",
+ "var let",
+ // Unrelated parser crash BUG(v8:4462)
+ // "var [let]",
+ "for (const let = 1; let < 1; let++) {}",
+ "for (const let in {}) {}",
+ "for (const [let] = 1; let < 1; let++) {}",
+ // Unrelated parser crash BUG(v8:4461)
+ // "for (const [let] in {}) {}",
+ "const let",
+ "const [let]",
NULL
};
// clang-format on
- static const ParserFlag always_flags[] = {kAllowHarmonySloppy,
- kAllowHarmonySloppyLet};
+ static const ParserFlag always_flags[] = {
+ kAllowHarmonySloppy, kAllowHarmonySloppyLet, kAllowHarmonyDestructuring};
RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags,
arraysize(always_flags));
+
+ // Some things should be rejected even in sloppy mode
+ // This addresses BUG(v8:4403).
+
+ // clang-format off
+ const char* fail_data[] = {
+ "let let = 1",
+ "for (let let = 1; let < 1; let++) {}",
+ "for (let let in {}) {}",
+ "for (let let of []) {}",
+ "const let = 1",
+ "for (const let = 1; let < 1; let++) {}",
+ "for (const let in {}) {}",
+ "for (const let of []) {}",
+ "let [let] = 1",
+ "for (let [let] = 1; let < 1; let++) {}",
+ "for (let [let] in {}) {}",
+ "for (let [let] of []) {}",
+ "const [let] = 1",
+ "for (const [let] = 1; let < 1; let++) {}",
+ "for (const [let] in {}) {}",
+ "for (const [let] of []) {}",
+ NULL
+ };
+ // clang-format on
+
+ static const ParserFlag fail_flags[] = {
+ kAllowHarmonySloppy, kAllowHarmonySloppyLet, kNoLegacyConst,
+ kAllowHarmonyDestructuring};
+ RunParserSyncTest(context_data, fail_data, kError, NULL, 0, fail_flags,
+ arraysize(fail_flags));
}
« no previous file with comments | « src/preparser.cc ('k') | test/message/let-lexical-name-prohibited.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698