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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 TEST(Parser, FunctionCall) { | 118 TEST(Parser, FunctionCall) { |
119 DoExpressionPrintTest("foo()", | 119 DoExpressionPrintTest("foo()", |
120 "FUNCTION(foo)\n" | 120 "FUNCTION(foo)\n" |
121 " LIST\n"); | 121 " LIST\n"); |
122 DoExpressionPrintTest("blah(1, 2)", | 122 DoExpressionPrintTest("blah(1, 2)", |
123 "FUNCTION(blah)\n" | 123 "FUNCTION(blah)\n" |
124 " LIST\n" | 124 " LIST\n" |
125 " LITERAL(1)\n" | 125 " LITERAL(1)\n" |
126 " LITERAL(2)\n"); | 126 " LITERAL(2)\n"); |
127 DoExpressionErrorTest("foo(1, 2,)", 1, 10); | 127 DoExpressionErrorTest("foo(1, 2,)", 1, 10); |
| 128 DoExpressionErrorTest("foo(1 2)", 1, 7); |
128 } | 129 } |
129 | 130 |
130 TEST(Parser, ParenExpression) { | 131 TEST(Parser, ParenExpression) { |
131 const char* input = "(foo(1)) + (a + (b - c) + d)"; | 132 const char* input = "(foo(1)) + (a + (b - c) + d)"; |
132 const char* expected = | 133 const char* expected = |
133 "BINARY(+)\n" | 134 "BINARY(+)\n" |
134 " FUNCTION(foo)\n" | 135 " FUNCTION(foo)\n" |
135 " LIST\n" | 136 " LIST\n" |
136 " LITERAL(1)\n" | 137 " LITERAL(1)\n" |
137 " BINARY(+)\n" | 138 " BINARY(+)\n" |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 DoParserPrintTest(input, expected); | 491 DoParserPrintTest(input, expected); |
491 } | 492 } |
492 | 493 |
493 TEST(Parser, HangingIf) { | 494 TEST(Parser, HangingIf) { |
494 DoParserErrorTest("if", 1, 1); | 495 DoParserErrorTest("if", 1, 1); |
495 } | 496 } |
496 | 497 |
497 TEST(Parser, NegatingList) { | 498 TEST(Parser, NegatingList) { |
498 DoParserErrorTest("executable(\"wee\") { sources =- [ \"foo.cc\" ] }", 1, 30); | 499 DoParserErrorTest("executable(\"wee\") { sources =- [ \"foo.cc\" ] }", 1, 30); |
499 } | 500 } |
OLD | NEW |