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 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 " BINARY(||)\n" | 484 " BINARY(||)\n" |
485 " BINARY(&&)\n" | 485 " BINARY(&&)\n" |
486 " BINARY(+)\n" | 486 " BINARY(+)\n" |
487 " IDENTIFIER(b)\n" | 487 " IDENTIFIER(b)\n" |
488 " IDENTIFIER(c)\n" | 488 " IDENTIFIER(c)\n" |
489 " IDENTIFIER(d)\n" | 489 " IDENTIFIER(d)\n" |
490 " IDENTIFIER(e)\n"; | 490 " IDENTIFIER(e)\n"; |
491 DoParserPrintTest(input, expected); | 491 DoParserPrintTest(input, expected); |
492 } | 492 } |
493 | 493 |
| 494 TEST(Parser, CommentsStandalone) { |
| 495 const char* input = "# Toplevel comment.\n\nexecutable(\"wee\") {}\n"; |
| 496 const char* expected = |
| 497 "BLOCK\n" |
| 498 " +BEFORE_COMMENT(\"# Toplevel comment.\")\n" |
| 499 " FUNCTION(executable)\n" |
| 500 " LIST\n" |
| 501 " LITERAL(\"wee\")\n" |
| 502 " BLOCK\n"; |
| 503 DoParserPrintTest(input, expected); |
| 504 } |
| 505 |
| 506 TEST(Parser, CommentsStandaloneEof) { |
| 507 const char* input = "executable(\"wee\") {}\n# EOF comment.\n"; |
| 508 const char* expected = |
| 509 "BLOCK\n" |
| 510 " +AFTER_COMMENT(\"# EOF comment.\")\n" |
| 511 " FUNCTION(executable)\n" |
| 512 " LIST\n" |
| 513 " LITERAL(\"wee\")\n" |
| 514 " BLOCK\n"; |
| 515 DoParserPrintTest(input, expected); |
| 516 } |
| 517 |
| 518 /* TODO(scottmg): Not implemented yet. |
| 519 TEST(Parser, CommentsSuffix) { |
| 520 const char* input = "executable(\"wee\") { # This is some stuff.\n" |
| 521 "sources = [ \"a.cc\"\n" |
| 522 "] }"; |
| 523 const char* expected = |
| 524 "BLOCK\n" |
| 525 " FUNCTION(executable)\n" |
| 526 " LIST\n" |
| 527 " LITERAL(\"wee\")\n" |
| 528 " +SUFFIX_COMMENT(\"# This is some stuff.\")\n" |
| 529 " BLOCK\n" |
| 530 " BINARY(=)\n" |
| 531 " IDENTIFIER(sources)\n" |
| 532 " LIST\n" |
| 533 " LITERAL(\"a.cc\")\n" |
| 534 " +SUFFIX_COMMENT(\"# And another comment here.\")\n"; |
| 535 DoParserPrintTest(input, expected); |
| 536 } |
| 537 */ |
| 538 |
494 TEST(Parser, HangingIf) { | 539 TEST(Parser, HangingIf) { |
495 DoParserErrorTest("if", 1, 1); | 540 DoParserErrorTest("if", 1, 1); |
496 } | 541 } |
497 | 542 |
498 TEST(Parser, NegatingList) { | 543 TEST(Parser, NegatingList) { |
499 DoParserErrorTest("executable(\"wee\") { sources =- [ \"foo.cc\" ] }", 1, 30); | 544 DoParserErrorTest("executable(\"wee\") { sources =- [ \"foo.cc\" ] }", 1, 30); |
500 } | 545 } |
OLD | NEW |