OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 2454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2465 | 2465 |
2466 const char* statement_data[] = { | 2466 const char* statement_data[] = { |
2467 statement, | 2467 statement, |
2468 NULL | 2468 NULL |
2469 }; | 2469 }; |
2470 | 2470 |
2471 // The test is quite slow, so run it with a reduced set of flags. | 2471 // The test is quite slow, so run it with a reduced set of flags. |
2472 static const ParserFlag empty_flags[] = {kAllowLazy}; | 2472 static const ParserFlag empty_flags[] = {kAllowLazy}; |
2473 RunParserSyncTest(context_data, statement_data, kError, empty_flags, 1); | 2473 RunParserSyncTest(context_data, statement_data, kError, empty_flags, 1); |
2474 } | 2474 } |
| 2475 |
| 2476 |
| 2477 TEST(StrictDelete) { |
| 2478 // "delete <Identifier>" is not allowed in strict mode. |
| 2479 const char* strict_context_data[][2] = { |
| 2480 {"\"use strict\"; ", ""}, |
| 2481 { NULL, NULL } |
| 2482 }; |
| 2483 |
| 2484 const char* sloppy_context_data[][2] = { |
| 2485 {"", ""}, |
| 2486 { NULL, NULL } |
| 2487 }; |
| 2488 |
| 2489 // These are errors in the strict mode. |
| 2490 const char* sloppy_statement_data[] = { |
| 2491 "delete foo;", |
| 2492 "delete foo + 1;", |
| 2493 "delete (foo);", |
| 2494 "delete eval;", |
| 2495 "delete interface;", |
| 2496 NULL |
| 2497 }; |
| 2498 |
| 2499 // These are always OK |
| 2500 const char* good_statement_data[] = { |
| 2501 "delete this;", |
| 2502 "delete 1;", |
| 2503 "delete 1 + 2;", |
| 2504 "delete foo();", |
| 2505 "delete foo.bar;", |
| 2506 "delete foo[bar];", |
| 2507 "delete foo--;", |
| 2508 "delete --foo;", |
| 2509 "delete new foo();", |
| 2510 "delete new foo(bar);", |
| 2511 NULL |
| 2512 }; |
| 2513 |
| 2514 // These are always errors |
| 2515 const char* bad_statement_data[] = { |
| 2516 "delete if;", |
| 2517 NULL |
| 2518 }; |
| 2519 |
| 2520 RunParserSyncTest(strict_context_data, sloppy_statement_data, kError); |
| 2521 RunParserSyncTest(sloppy_context_data, sloppy_statement_data, kSuccess); |
| 2522 |
| 2523 RunParserSyncTest(strict_context_data, good_statement_data, kSuccess); |
| 2524 RunParserSyncTest(sloppy_context_data, good_statement_data, kSuccess); |
| 2525 |
| 2526 RunParserSyncTest(strict_context_data, bad_statement_data, kError); |
| 2527 RunParserSyncTest(sloppy_context_data, bad_statement_data, kError); |
| 2528 } |
OLD | NEW |