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

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

Issue 927953003: [strong] Forbid var. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: loop w const omg Created 5 years, 10 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/mjsunit/strong/var-let-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 7a624cb0bf38f99a55ade2350f72af62986ed960..9eb5d947a6e7ec63e262cd15d73e590ef7e2840c 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -5453,3 +5453,57 @@ TEST(FunctionLiteralDuplicateParameters) {
arraysize(always_flags));
RunParserSyncTest(sloppy_context_data, data, kSuccess, NULL, 0, NULL, 0);
}
+
+
+TEST(VarForbiddenInStrongMode) {
+ const char* strong_context_data[][2] =
+ {{"'use strong'; ", ""},
+ {"function f() {'use strong'; ", "}"},
+ {"function f() {'use strong'; while (true) { ", "} }"},
+ {NULL, NULL}};
+
+ const char* strict_context_data[][2] =
+ {{"'use strict'; ", ""},
+ {"function f() {'use strict'; ", "}"},
+ {"function f() {'use strict'; while (true) { ", "} }"},
+ {NULL, NULL}};
+
+ const char* sloppy_context_data[][2] =
+ {{"", ""},
+ {"function f() { ", "}"},
+ {NULL, NULL}};
+
+ const char* var_declarations[] = {
+ "var x = 0;",
+ "for (var i = 0; i < 10; i++) { }",
+ NULL};
+
+ const char* let_declarations[] = {
+ "let x = 0;",
+ "for (let i = 0; i < 10; i++) { }",
+ NULL};
+
+ const char* const_declarations[] = {
+ "const x = 0;",
+ NULL};
+
+ static const ParserFlag always_flags[] = {kAllowStrongMode,
+ kAllowHarmonyScoping};
+ RunParserSyncTest(strong_context_data, var_declarations, kError, NULL, 0,
+ always_flags, arraysize(always_flags));
+ RunParserSyncTest(strong_context_data, let_declarations, kSuccess, NULL, 0,
+ always_flags, arraysize(always_flags));
+ RunParserSyncTest(strong_context_data, const_declarations, kSuccess, NULL, 0,
+ always_flags, arraysize(always_flags));
+
+ RunParserSyncTest(strict_context_data, var_declarations, kSuccess, NULL, 0,
+ always_flags, arraysize(always_flags));
+ RunParserSyncTest(strict_context_data, let_declarations, kSuccess, NULL, 0,
+ always_flags, arraysize(always_flags));
+
+ RunParserSyncTest(sloppy_context_data, var_declarations, kSuccess, NULL, 0,
+ always_flags, arraysize(always_flags));
+ // At the moment, let declarations are only available in strict mode.
+ RunParserSyncTest(sloppy_context_data, let_declarations, kError, NULL, 0,
+ always_flags, arraysize(always_flags));
+}
« no previous file with comments | « src/preparser.cc ('k') | test/mjsunit/strong/var-let-const.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698