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

Unified Diff: tools/gn/parser_unittest.cc

Issue 607173002: gn format: fix comments at end of blocks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/parser.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/parser_unittest.cc
diff --git a/tools/gn/parser_unittest.cc b/tools/gn/parser_unittest.cc
index 226143ac8f6a46d9d128dd7ab4ce41a7a5fc07a6..1a3df4aa695b9872b96b6889bdc7e90b3dfb8dcf 100644
--- a/tools/gn/parser_unittest.cc
+++ b/tools/gn/parser_unittest.cc
@@ -633,6 +633,41 @@ TEST(Parser, CommentsConnectedInList) {
DoParserPrintTest(input, expected);
}
+TEST(Parser, CommentsAtEndOfBlock) {
+ const char* input =
+ "if (is_win) {\n"
+ " sources = [\"a.cc\"]\n"
+ " # Some comment at end.\n"
+ "}\n";
+ const char* expected =
+ "BLOCK\n"
+ " CONDITION\n"
+ " IDENTIFIER(is_win)\n"
+ " BLOCK\n"
+ " BINARY(=)\n"
+ " IDENTIFIER(sources)\n"
+ " LIST\n"
+ " LITERAL(\"a.cc\")\n"
+ " END(})\n"
+ " +BEFORE_COMMENT(\"# Some comment at end.\")\n";
+ DoParserPrintTest(input, expected);
+}
+
+// TODO(scottmg): I could be convinced this is incorrect. It's not clear to me
+// which thing this comment is intended to be attached to.
+TEST(Parser, CommentsEndOfBlockSingleLine) {
+ const char* input =
+ "defines = [ # EOL defines.\n"
+ "]\n";
+ const char* expected =
+ "BLOCK\n"
+ " BINARY(=)\n"
+ " IDENTIFIER(defines)\n"
+ " +SUFFIX_COMMENT(\"# EOL defines.\")\n"
+ " LIST\n";
+ DoParserPrintTest(input, expected);
+}
+
TEST(Parser, HangingIf) {
DoParserErrorTest("if", 1, 1);
}
« no previous file with comments | « tools/gn/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698