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

Side by Side 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 unified diff | Download patch
« tools/gn/parser.cc ('K') | « tools/gn/parser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <iostream> 5 #include <iostream>
6 #include <sstream> 6 #include <sstream>
7 7
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "tools/gn/input_file.h" 9 #include "tools/gn/input_file.h"
10 #include "tools/gn/parser.h" 10 #include "tools/gn/parser.h"
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 DoParserPrintTest(input, expected); 670 DoParserPrintTest(input, expected);
671 } 671 }
672 672
673 TEST(Parser, HangingIf) { 673 TEST(Parser, HangingIf) {
674 DoParserErrorTest("if", 1, 1); 674 DoParserErrorTest("if", 1, 1);
675 } 675 }
676 676
677 TEST(Parser, NegatingList) { 677 TEST(Parser, NegatingList) {
678 DoParserErrorTest("executable(\"wee\") { sources =- [ \"foo.cc\" ] }", 1, 30); 678 DoParserErrorTest("executable(\"wee\") { sources =- [ \"foo.cc\" ] }", 1, 30);
679 } 679 }
680
681 TEST(Parser, ConditionNoBracesIf) {
682 DoParserErrorTest(
683 "if (true)\n"
684 " foreach(foo, []) {}\n"
685 "else {\n"
686 " foreach(bar, []) {}\n"
687 "}\n",
688 2, 3);
689 }
690
691 TEST(Parser, ConditionNoBracesElse) {
692 DoParserErrorTest(
693 "if (true) {\n"
694 " foreach(foo, []) {}\n"
695 "} else\n"
696 " foreach(bar, []) {}\n",
697 4, 3);
698 }
699
700 TEST(Parser, ConditionNoBracesElseIf) {
701 DoParserErrorTest(
702 "if (true) {\n"
703 " foreach(foo, []) {}\n"
704 "} else if (true)\n"
705 " foreach(bar, []) {}\n",
706 4, 3);
707 }
OLDNEW
« 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