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

Side by Side Diff: test/cctest/test-parsing.cc

Issue 196343033: Make PreParser track valid left hand sides. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/preparser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2508 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 "new foo()[bar]",
2560 "new foo().bar",
2561 NULL
2562 };
2563
2564 // Bad left hand sides for assigment or prefix / postfix operations.
2565 const char* bad_statement_data_common[] = {
2566 "2",
2567 "foo()",
2568 "null",
2569 "if", // Unexpected token
2570 "{x: 1}", // Unexpected token
2571 "this",
2572 "\"bar\"",
2573 "(foo + bar)",
2574 "new new foo()[bar]", // means: new (new foo()[bar])
2575 "new new foo().bar", // means: new (new foo()[bar])
2576 NULL
2577 };
2578
2579 // These are not okay for assignment, but okay for prefix / postix.
2580 const char* bad_statement_data_for_assignment[] = {
2581 "++foo",
2582 "foo++",
2583 "foo + bar",
2584 NULL
2585 };
2586
2587 RunParserSyncTest(assignment_context_data, good_statement_data, kSuccess);
2588 RunParserSyncTest(assignment_context_data, bad_statement_data_common, kError);
2589 RunParserSyncTest(assignment_context_data, bad_statement_data_for_assignment,
2590 kError);
2591
2592 RunParserSyncTest(prefix_context_data, good_statement_data, kSuccess);
2593 RunParserSyncTest(prefix_context_data, bad_statement_data_common, kError);
2594
2595 RunParserSyncTest(postfix_context_data, good_statement_data, kSuccess);
2596 // TODO(marja): This doesn't work yet.
2597 // RunParserSyncTest(postfix_context_data, bad_statement_data_common, kError);
2598 }
OLDNEW
« 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