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 2315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2326 {"", ""}, | 2326 {"", ""}, |
2327 {"var f =", ""}, | 2327 {"var f =", ""}, |
2328 { NULL, NULL } | 2328 { NULL, NULL } |
2329 }; | 2329 }; |
2330 | 2330 |
2331 const char* statement_data[] = { | 2331 const char* statement_data[] = { |
2332 "new foo bar", | 2332 "new foo bar", |
2333 "new ) foo", | 2333 "new ) foo", |
2334 "new ++foo", | 2334 "new ++foo", |
2335 // TODO(marja): Activate this test once the preparser checks correctly. | 2335 // TODO(marja): Activate this test once the preparser checks correctly. |
2336 // "new foo ++", | 2336 // "new foo ++", |
rossberg
2014/03/19 15:29:08
Can we activate this one now?
marja
2014/03/19 15:41:15
Not yet; this will start working when ParseMemberW
| |
2337 NULL | 2337 NULL |
2338 }; | 2338 }; |
2339 | 2339 |
2340 RunParserSyncTest(context_data, statement_data, kError); | 2340 RunParserSyncTest(context_data, statement_data, kError); |
2341 } | 2341 } |
2342 | 2342 |
2343 | 2343 |
2344 TEST(StrictObjectLiteralChecking) { | 2344 TEST(StrictObjectLiteralChecking) { |
2345 const char* strict_context_data[][2] = { | 2345 const char* strict_context_data[][2] = { |
2346 {"\"use strict\"; var myobject = {", "};"}, | 2346 {"\"use strict\"; var myobject = {", "};"}, |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2519 | 2519 |
2520 RunParserSyncTest(strict_context_data, sloppy_statement_data, kError); | 2520 RunParserSyncTest(strict_context_data, sloppy_statement_data, kError); |
2521 RunParserSyncTest(sloppy_context_data, sloppy_statement_data, kSuccess); | 2521 RunParserSyncTest(sloppy_context_data, sloppy_statement_data, kSuccess); |
2522 | 2522 |
2523 RunParserSyncTest(strict_context_data, good_statement_data, kSuccess); | 2523 RunParserSyncTest(strict_context_data, good_statement_data, kSuccess); |
2524 RunParserSyncTest(sloppy_context_data, good_statement_data, kSuccess); | 2524 RunParserSyncTest(sloppy_context_data, good_statement_data, kSuccess); |
2525 | 2525 |
2526 RunParserSyncTest(strict_context_data, bad_statement_data, kError); | 2526 RunParserSyncTest(strict_context_data, bad_statement_data, kError); |
2527 RunParserSyncTest(sloppy_context_data, bad_statement_data, kError); | 2527 RunParserSyncTest(sloppy_context_data, bad_statement_data, kError); |
2528 } | 2528 } |
2529 | |
2530 | |
2531 TEST(ErrorInvalidLeftHandSide) { | |
2532 const char* assignment_context_data[][2] = { | |
2533 // {"", " = 1;"}, | |
2534 // {"\"use strict\"; ", " = 1;"}, | |
2535 { NULL, NULL } | |
2536 }; | |
2537 | |
2538 const char* prefix_context_data[][2] = { | |
2539 {"++", ";"}, | |
2540 {"\"use strict\"; ++", ";"}, | |
2541 {NULL, NULL}, | |
2542 }; | |
2543 | |
2544 const char* postfix_context_data[][2] = { | |
2545 {"", "++;"}, | |
2546 {"\"use strict\"; ", "++;"}, | |
2547 { NULL, NULL } | |
2548 }; | |
2549 | |
2550 // Good left hand sides for assigment or prefix / postfix operations. | |
2551 const char* good_statement_data[] = { | |
2552 "foo", | |
2553 "foo.bar", | |
2554 "foo[bar]", | |
2555 "foo()[bar]", | |
2556 "foo().bar", | |
2557 "this.foo", | |
2558 "this[foo]", | |
2559 NULL | |
2560 }; | |
2561 | |
2562 // Bad left hand sides for assigment or prefix / postfix operations. | |
2563 const char* bad_statement_data_common[] = { | |
2564 "2", | |
2565 "foo()", | |
2566 "null", | |
2567 "if", // Unexpected token | |
2568 "{x: 1}", // Unexpected token | |
2569 "this", | |
2570 "\"bar\"", | |
2571 "(foo + bar)", | |
2572 NULL | |
2573 }; | |
2574 | |
2575 // These are not okay for assignment, but okay for prefix / postix. | |
2576 const char* bad_statement_data_for_assignment[] = { | |
2577 "++foo", | |
2578 "foo++", | |
2579 "foo + bar", | |
2580 NULL | |
2581 }; | |
2582 | |
2583 RunParserSyncTest(assignment_context_data, good_statement_data, kSuccess); | |
2584 RunParserSyncTest(assignment_context_data, bad_statement_data_common, kError); | |
2585 RunParserSyncTest(assignment_context_data, bad_statement_data_for_assignment, | |
2586 kError); | |
2587 | |
2588 RunParserSyncTest(prefix_context_data, good_statement_data, kSuccess); | |
2589 RunParserSyncTest(prefix_context_data, bad_statement_data_common, kError); | |
2590 | |
2591 RunParserSyncTest(postfix_context_data, good_statement_data, kSuccess); | |
2592 // TODO(marja): This doesn't work yet. | |
rossberg
2014/03/19 15:29:08
Hm, why?
marja
2014/03/19 15:41:15
Because the check is in ParsePostfixExpression whi
| |
2593 // RunParserSyncTest(postfix_context_data, bad_statement_data_common, kError); | |
2594 } | |
OLD | NEW |