Index: tools/gn/parser_unittest.cc |
diff --git a/tools/gn/parser_unittest.cc b/tools/gn/parser_unittest.cc |
index 1205038a8bccf7cf92b1c04c598ac5425cb48014..09930a461d6c64f5917d9c2ddca5c9690fec164a 100644 |
--- a/tools/gn/parser_unittest.cc |
+++ b/tools/gn/parser_unittest.cc |
@@ -491,6 +491,51 @@ TEST(Parser, LongExpression) { |
DoParserPrintTest(input, expected); |
} |
+TEST(Parser, CommentsStandalone) { |
+ const char* input = "# Toplevel comment.\n\nexecutable(\"wee\") {}\n"; |
+ const char* expected = |
+ "BLOCK\n" |
+ " +BEFORE_COMMENT(\"# Toplevel comment.\")\n" |
+ " FUNCTION(executable)\n" |
+ " LIST\n" |
+ " LITERAL(\"wee\")\n" |
+ " BLOCK\n"; |
+ DoParserPrintTest(input, expected); |
+} |
+ |
+TEST(Parser, CommentsStandaloneEof) { |
+ const char* input = "executable(\"wee\") {}\n# EOF comment.\n"; |
+ const char* expected = |
+ "BLOCK\n" |
+ " +AFTER_COMMENT(\"# EOF comment.\")\n" |
+ " FUNCTION(executable)\n" |
+ " LIST\n" |
+ " LITERAL(\"wee\")\n" |
+ " BLOCK\n"; |
+ DoParserPrintTest(input, expected); |
+} |
+ |
+/* TODO(scottmg): Not implemented yet. |
+TEST(Parser, CommentsSuffix) { |
+ const char* input = "executable(\"wee\") { # This is some stuff.\n" |
+ "sources = [ \"a.cc\"\n" |
+ "] }"; |
+ const char* expected = |
+ "BLOCK\n" |
+ " FUNCTION(executable)\n" |
+ " LIST\n" |
+ " LITERAL(\"wee\")\n" |
+ " +SUFFIX_COMMENT(\"# This is some stuff.\")\n" |
+ " BLOCK\n" |
+ " BINARY(=)\n" |
+ " IDENTIFIER(sources)\n" |
+ " LIST\n" |
+ " LITERAL(\"a.cc\")\n" |
+ " +SUFFIX_COMMENT(\"# And another comment here.\")\n"; |
+ DoParserPrintTest(input, expected); |
+} |
+*/ |
+ |
TEST(Parser, HangingIf) { |
DoParserErrorTest("if", 1, 1); |
} |