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

Unified Diff: tools/gn/parser_unittest.cc

Issue 996893002: gn: Enforce braces after 'else' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« tools/gn/parser.cc ('K') | « 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 4ebefb20f89d323ada9b0fcb0804eec853606fd6..823a9830588948c535e831cc2a47c2efc5c28812 100644
--- a/tools/gn/parser_unittest.cc
+++ b/tools/gn/parser_unittest.cc
@@ -677,3 +677,31 @@ TEST(Parser, HangingIf) {
TEST(Parser, NegatingList) {
DoParserErrorTest("executable(\"wee\") { sources =- [ \"foo.cc\" ] }", 1, 30);
}
+
+TEST(Parser, ConditionNoBracesIf) {
+ DoParserErrorTest(
+ "if (true)\n"
+ " foreach(foo, []) {}\n"
+ "else {\n"
+ " foreach(bar, []) {}\n"
+ "}\n",
+ 2, 3);
+}
+
+TEST(Parser, ConditionNoBracesElse) {
+ DoParserErrorTest(
+ "if (true) {\n"
+ " foreach(foo, []) {}\n"
+ "} else\n"
+ " foreach(bar, []) {}\n",
+ 4, 3);
+}
+
+TEST(Parser, ConditionNoBracesElseIf) {
+ DoParserErrorTest(
+ "if (true) {\n"
+ " foreach(foo, []) {}\n"
+ "} else if (true)\n"
+ " foreach(bar, []) {}\n",
+ 4, 3);
+}
« tools/gn/parser.cc ('K') | « tools/gn/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698