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

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

Issue 2586073002: Revert GN declare_args() change. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « tools/gn/functions.cc ('k') | tools/gn/parse_tree.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "tools/gn/functions.h" 5 #include "tools/gn/functions.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 input.parsed()->Execute(setup.scope(), &err); 118 input.parsed()->Execute(setup.scope(), &err);
119 ASSERT_FALSE(err.has_error()) << err.message(); 119 ASSERT_FALSE(err.has_error()) << err.message();
120 120
121 EXPECT_EQ( 121 EXPECT_EQ(
122 "empty = [[]] [[], [], []]\n" 122 "empty = [[]] [[], [], []]\n"
123 "one = [[1]] [[1], []]\n" 123 "one = [[1]] [[1], []]\n"
124 "many = [[1, 2, 3, 4, 5], [6, 7, 8, 9]]\n" 124 "many = [[1, 2, 3, 4, 5], [6, 7, 8, 9]]\n"
125 "rounding = [[1, 2], [3, 4], [5], [6]]\n", 125 "rounding = [[1, 2], [3, 4], [5], [6]]\n",
126 setup.print_output()); 126 setup.print_output());
127 } 127 }
128
129 TEST(Functions, DeclareArgs) {
130 TestWithScope setup;
131 Err err;
132
133 // It is not legal to read the value of an argument declared in a
134 // declare_args() from inside the call, but outside the call and in
135 // a separate call should work.
136
137 TestParseInput reading_from_same_call(R"(
138 declare_args() {
139 foo = true
140 bar = foo
141 })");
142 reading_from_same_call.parsed()->Execute(setup.scope(), &err);
143 ASSERT_TRUE(err.has_error());
144
145 TestParseInput reading_from_outside_call(R"(
146 declare_args() {
147 foo = true
148 }
149
150 bar = foo
151 assert(bar)
152 )");
153 err = Err();
154 reading_from_outside_call.parsed()->Execute(setup.scope(), &err);
155 ASSERT_FALSE(err.has_error());
156
157 TestParseInput reading_from_different_call(R"(
158 declare_args() {
159 foo = true
160 }
161
162 declare_args() {
163 bar = foo
164 }
165
166 assert(bar)
167 )");
168 err = Err();
169 TestWithScope setup2;
170 reading_from_different_call.parsed()->Execute(setup2.scope(), &err);
171 ASSERT_FALSE(err.has_error());
172 }
OLDNEW
« no previous file with comments | « tools/gn/functions.cc ('k') | tools/gn/parse_tree.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698