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

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

Issue 203193004: Move ParseUnaryExpression into ParserBase and add tests. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: clang build fixes Created 6 years, 9 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') | 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 5a2ee1303852b9ab440351b8f16b9f67fdec81db..c88b2dc4464193b2cd4eee714f35df26dd50af3b 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -2472,3 +2472,57 @@ TEST(TooManyArguments) {
static const ParserFlag empty_flags[] = {kAllowLazy};
RunParserSyncTest(context_data, statement_data, kError, empty_flags, 1);
}
+
+
+TEST(StrictDelete) {
+ // "delete <Identifier>" is not allowed in strict mode.
+ const char* strict_context_data[][2] = {
+ {"\"use strict\"; ", ""},
+ { NULL, NULL }
+ };
+
+ const char* sloppy_context_data[][2] = {
+ {"", ""},
+ { NULL, NULL }
+ };
+
+ // These are errors in the strict mode.
+ const char* sloppy_statement_data[] = {
+ "delete foo;",
+ "delete foo + 1;",
+ "delete (foo);",
+ "delete eval;",
+ "delete interface;",
+ NULL
+ };
+
+ // These are always OK
+ const char* good_statement_data[] = {
+ "delete this;",
+ "delete 1;",
+ "delete 1 + 2;",
+ "delete foo();",
+ "delete foo.bar;",
+ "delete foo[bar];",
+ "delete foo--;",
+ "delete --foo;",
+ "delete new foo();",
+ "delete new foo(bar);",
+ NULL
+ };
+
+ // These are always errors
+ const char* bad_statement_data[] = {
+ "delete if;",
+ NULL
+ };
+
+ RunParserSyncTest(strict_context_data, sloppy_statement_data, kError);
+ RunParserSyncTest(sloppy_context_data, sloppy_statement_data, kSuccess);
+
+ RunParserSyncTest(strict_context_data, good_statement_data, kSuccess);
+ RunParserSyncTest(sloppy_context_data, good_statement_data, kSuccess);
+
+ RunParserSyncTest(strict_context_data, bad_statement_data, kError);
+ RunParserSyncTest(sloppy_context_data, bad_statement_data, kError);
+}
« no previous file with comments | « src/preparser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698