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

Side by Side Diff: tools/gn/parser_unittest.cc

Issue 1015063003: tools/gn: add "gn help grammar" with formal grammar (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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 }
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