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

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

Issue 2233893005: GN: Mark all variables used when defining a template. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tests Created 4 years, 4 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
« no previous file with comments | « tools/gn/function_template.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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "tools/gn/test_with_scope.h"
7
8 // Checks that variables used inside template definitions aren't reported
9 // unused if they were declared above the template.
10 TEST(FunctionTemplate, MarkUsed) {
11 TestWithScope setup;
12 TestParseInput input(
13 "a = 1\n" // Unused outside of template.
14 "template(\"templ\") {\n"
15 " print(a)\n"
16 "}\n");
17 ASSERT_FALSE(input.has_error()) << input.parse_err().message();
18
19 Err err;
20 input.parsed()->Execute(setup.scope(), &err);
21 ASSERT_FALSE(err.has_error()) << err.message();
22
23 // Normally the loader calls CheckForUnusedVars() when it loads a file
24 // since normal blocks don't do this check. To avoid having to make this
25 // test much more complicated, just explicitly do the check to make sure
26 // things are marked properly.
27 setup.scope()->CheckForUnusedVars(&err);
28 EXPECT_FALSE(err.has_error());
29 }
OLDNEW
« no previous file with comments | « tools/gn/function_template.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698