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

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

Issue 1084983002: [strong] Implement static restrictions on switch statement (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 487a7bff5fb7ab3cb800037246add55f939d6fb8..8a5b564e1b797dec1b98992576f26e68e95af16c 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -5975,31 +5975,79 @@ TEST(StrongUndefinedArrow) {
TEST(StrongDirectEval) {
- const char* context_data[][2] = {{"", ""}, {NULL}};
+ const char* sloppy_context_data[][2] = {{"", ""}, {NULL}};
+ const char* strong_context_data[][2] = {{"'use strong';", ""}, {NULL}};
const char* error_data[] = {
- "'use strong'; eval();",
- "'use strong'; eval([]);",
- "'use strong'; (eval)();",
- "'use strong'; (((eval)))();",
- "'use strong'; eval('function f() {}');",
- "'use strong'; function f() {eval()}",
+ "eval();",
+ "eval([]);",
+ "(eval)();",
+ "(((eval)))();",
+ "eval('function f() {}');",
+ "function f() {eval()}",
NULL};
const char* success_data[] = {
- "'use strong'; eval;",
- "'use strong'; eval`foo`;",
- "'use strong'; let foo = eval; foo();",
- "'use strong'; (1, eval)();",
+ "eval;",
+ "eval`foo`;",
+ "let foo = eval; foo();",
+ "(1, eval)();",
NULL};
static const ParserFlag always_flags[] = {
kAllowStrongMode
};
- RunParserSyncTest(context_data, error_data, kError, NULL, 0,
+ RunParserSyncTest(sloppy_context_data, error_data, kSuccess, NULL, 0,
always_flags, arraysize(always_flags));
- RunParserSyncTest(context_data, success_data, kSuccess, NULL, 0,
+ RunParserSyncTest(strong_context_data, error_data, kError, NULL, 0,
+ always_flags, arraysize(always_flags));
+ RunParserSyncTest(strong_context_data, success_data, kSuccess, NULL, 0,
+ always_flags, arraysize(always_flags));
+}
+
+
+TEST(StrongSwitchTerminators) {
+ const char* sloppy_context_data[][2] = {
+ {"function f() { for(;;) { switch(1) {", "};}}"},
+ {NULL, NULL}
+ };
+ const char* strong_context_data[][2] = {
+ {"function f() { 'use strong'; for(;;) { switch(1) {", "};}}"},
+ {NULL, NULL}
+ };
+
+ const char* data_success[] = {
+ "",
+ "case 1:",
+ "case 1: case 2:",
+ "case 1: break;",
+ "default: throw new TypeError();",
+ "case 1: break; case 2: return; default:",
+ "case 1: case 2: break; case 3: continue; case 4: default:",
+ "case 1: case 2: {{return;}} case 3: default:",
+ "case 1: case 2: case 3: default: {1+1;{continue;}}",
+ "case 1: case 2: {1+1;{1+1;{continue;}}} case 3: default:",
+ NULL};
+
+ const char* data_error[] = {
+ "case 1: 1+1; case 2:",
+ "case 1: foo: break foo; case 2: break;",
+ "case 1: continue; case 2: foo: break foo;",
+ "case 1: foo:return;",
+ "case 1: foo:{ continue;}",
+ "case 1: break; default: foo:{ throw new TypeError() }",
+ "case 1: case 2: { foo:{ { break;} } } default: break;",
+ NULL};
+
+ static const ParserFlag always_flags[] = {
+ kAllowStrongMode
+ };
+ RunParserSyncTest(strong_context_data, data_success, kSuccess, NULL, 0,
+ always_flags, arraysize(always_flags));
+ RunParserSyncTest(sloppy_context_data, data_error, kSuccess, NULL, 0,
+ always_flags, arraysize(always_flags));
+ RunParserSyncTest(strong_context_data, data_error, kError, NULL, 0,
always_flags, arraysize(always_flags));
}
« 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