OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |