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

Unified Diff: tools/gn/parser_unittest.cc

Issue 1007963003: Fixes to {} handling in GN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 5 years, 9 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 823a9830588948c535e831cc2a47c2efc5c28812..6216ee4d6b178a06a91092593be0896093f7a247 100644
--- a/tools/gn/parser_unittest.cc
+++ b/tools/gn/parser_unittest.cc
@@ -363,25 +363,6 @@ TEST(Parser, FunctionWithConditional) {
DoParserPrintTest(input, expected);
}
-TEST(Parser, NestedBlocks) {
- const char* input = "{cc_test(\"foo\") {{foo=1}\n{}}}";
- const char* expected =
- "BLOCK\n"
- " BLOCK\n"
- " FUNCTION(cc_test)\n"
- " LIST\n"
- " LITERAL(\"foo\")\n"
- " BLOCK\n"
- " BLOCK\n"
- " BINARY(=)\n"
- " IDENTIFIER(foo)\n"
- " LITERAL(1)\n"
- " BLOCK\n";
- DoParserPrintTest(input, expected);
- const char* input_with_newline = "{cc_test(\"foo\") {{foo=1}\n{}}}";
- DoParserPrintTest(input_with_newline, expected);
-}
-
TEST(Parser, UnterminatedBlock) {
DoParserErrorTest("stuff() {", 1, 9);
}
@@ -705,3 +686,18 @@ TEST(Parser, ConditionNoBracesElseIf) {
" foreach(bar, []) {}\n",
4, 3);
}
+
+// Disallow standalone {} for introducing new scopes. These are ambiguous with
+// target declarations (e.g. is:
+// foo("bar") {}
+// a function with an associated block, or a standalone function with a
+// freestanding block.
+TEST(Parser, StandaloneBlock) {
+ DoParserErrorTest(
+ "if (true) {\n"
+ "}\n"
+ "{\n"
+ " assert(false)\n"
+ "}\n",
+ 3, 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