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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 | 117 |
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); | |
128 DoExpressionErrorTest("foo(1 2)", 1, 7); | 127 DoExpressionErrorTest("foo(1 2)", 1, 7); |
129 } | 128 } |
130 | 129 |
131 TEST(Parser, ParenExpression) { | 130 TEST(Parser, ParenExpression) { |
132 const char* input = "(foo(1)) + (a + (b - c) + d)"; | 131 const char* input = "(foo(1)) + (a + (b - c) + d)"; |
133 const char* expected = | 132 const char* expected = |
134 "BINARY(+)\n" | 133 "BINARY(+)\n" |
135 " FUNCTION(foo)\n" | 134 " FUNCTION(foo)\n" |
136 " LIST\n" | 135 " LIST\n" |
137 " LITERAL(1)\n" | 136 " LITERAL(1)\n" |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 // freestanding block. | 693 // freestanding block. |
695 TEST(Parser, StandaloneBlock) { | 694 TEST(Parser, StandaloneBlock) { |
696 DoParserErrorTest( | 695 DoParserErrorTest( |
697 "if (true) {\n" | 696 "if (true) {\n" |
698 "}\n" | 697 "}\n" |
699 "{\n" | 698 "{\n" |
700 " assert(false)\n" | 699 " assert(false)\n" |
701 "}\n", | 700 "}\n", |
702 3, 1); | 701 3, 1); |
703 } | 702 } |
OLD | NEW |