OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <iostream> | 5 #include <iostream> |
6 #include <sstream> | 6 #include <sstream> |
7 | 7 |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "tools/gn/input_file.h" | 9 #include "tools/gn/input_file.h" |
10 #include "tools/gn/parser.h" | 10 #include "tools/gn/parser.h" |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 DoParserPrintTest(input, expected); | 491 DoParserPrintTest(input, expected); |
492 } | 492 } |
493 | 493 |
494 TEST(Parser, CommentsStandalone) { | 494 TEST(Parser, CommentsStandalone) { |
495 const char* input = | 495 const char* input = |
496 "# Toplevel comment.\n" | 496 "# Toplevel comment.\n" |
497 "\n" | 497 "\n" |
498 "executable(\"wee\") {}\n"; | 498 "executable(\"wee\") {}\n"; |
499 const char* expected = | 499 const char* expected = |
500 "BLOCK\n" | 500 "BLOCK\n" |
501 " +BEFORE_COMMENT(\"# Toplevel comment.\")\n" | 501 " BLOCK_COMMENT(# Toplevel comment.)\n" |
502 " FUNCTION(executable)\n" | 502 " FUNCTION(executable)\n" |
503 " LIST\n" | 503 " LIST\n" |
504 " LITERAL(\"wee\")\n" | 504 " LITERAL(\"wee\")\n" |
505 " BLOCK\n"; | 505 " BLOCK\n"; |
506 DoParserPrintTest(input, expected); | 506 DoParserPrintTest(input, expected); |
507 } | 507 } |
508 | 508 |
509 TEST(Parser, CommentsStandaloneEof) { | 509 TEST(Parser, CommentsStandaloneEof) { |
510 const char* input = | 510 const char* input = |
511 "executable(\"wee\") {}\n" | 511 "executable(\"wee\") {}\n" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 " BINARY(=)\n" | 607 " BINARY(=)\n" |
608 " IDENTIFIER(sources)\n" | 608 " IDENTIFIER(sources)\n" |
609 " LIST\n" | 609 " LIST\n" |
610 " LITERAL(\"a\")\n" | 610 " LITERAL(\"a\")\n" |
611 " +SUFFIX_COMMENT(\"# This is a comment,\")\n" | 611 " +SUFFIX_COMMENT(\"# This is a comment,\")\n" |
612 " +SUFFIX_COMMENT(\"# and some more,\")\n" | 612 " +SUFFIX_COMMENT(\"# and some more,\")\n" |
613 " +SUFFIX_COMMENT(\"# then the end.\")\n"; | 613 " +SUFFIX_COMMENT(\"# then the end.\")\n"; |
614 DoParserPrintTest(input, expected); | 614 DoParserPrintTest(input, expected); |
615 } | 615 } |
616 | 616 |
| 617 TEST(Parser, CommentsConnectedInList) { |
| 618 const char* input = |
| 619 "defines = [\n" |
| 620 "\n" |
| 621 " # Connected comment.\n" |
| 622 " \"WEE\",\n" |
| 623 " \"BLORPY\",\n" |
| 624 "]\n"; |
| 625 const char* expected = |
| 626 "BLOCK\n" |
| 627 " BINARY(=)\n" |
| 628 " IDENTIFIER(defines)\n" |
| 629 " LIST\n" |
| 630 " LITERAL(\"WEE\")\n" |
| 631 " +BEFORE_COMMENT(\"# Connected comment.\")\n" |
| 632 " LITERAL(\"BLORPY\")\n"; |
| 633 DoParserPrintTest(input, expected); |
| 634 } |
| 635 |
617 TEST(Parser, HangingIf) { | 636 TEST(Parser, HangingIf) { |
618 DoParserErrorTest("if", 1, 1); | 637 DoParserErrorTest("if", 1, 1); |
619 } | 638 } |
620 | 639 |
621 TEST(Parser, NegatingList) { | 640 TEST(Parser, NegatingList) { |
622 DoParserErrorTest("executable(\"wee\") { sources =- [ \"foo.cc\" ] }", 1, 30); | 641 DoParserErrorTest("executable(\"wee\") { sources =- [ \"foo.cc\" ] }", 1, 30); |
623 } | 642 } |
OLD | NEW |