Index: test/cctest/test-parsing.cc |
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc |
index 2e282cef8a52f0029680d45bae27b94a4a48ade6..e36c88a6d995eed1b588409e105a6808f3d98a33 100644 |
--- a/test/cctest/test-parsing.cc |
+++ b/test/cctest/test-parsing.cc |
@@ -2459,3 +2459,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); |
+} |