X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Ftools%2Fgn%2Fparser_unittest.cc;h=4ebefb20f89d323ada9b0fcb0804eec853606fd6;hb=1afa4dd80ef85af7c90efaea6959db1d92330844;hp=226143ac8f6a46d9d128dd7ab4ce41a7a5fc07a6;hpb=90762837333c13ccf56f2ad88e4481fc71e8d281;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/tools/gn/parser_unittest.cc b/src/tools/gn/parser_unittest.cc index 226143a..4ebefb2 100644 --- a/src/tools/gn/parser_unittest.cc +++ b/src/tools/gn/parser_unittest.cc @@ -558,6 +558,7 @@ TEST(Parser, CommentsSuffix) { " FUNCTION(executable)\n" " LIST\n" " LITERAL(\"wee\")\n" + " END())\n" " +SUFFIX_COMMENT(\"# This is some stuff.\")\n" " BLOCK\n" " BINARY(=)\n" @@ -585,6 +586,7 @@ TEST(Parser, CommentsSuffixDifferentLine) { " LIST\n" " LITERAL(\"a\")\n" " LITERAL(\"b\")\n" + " END(])\n" " +SUFFIX_COMMENT(\"# Comment\")\n"; DoParserPrintTest(input, expected); } @@ -633,6 +635,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); }