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

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

Issue 1263053003: Add forward_variables_from() and target() to GN (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
OLDNEW
(Empty)
1 // Copyright 2015 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/scheduler.h"
7 #include "tools/gn/test_with_scope.h"
8
9 TEST(FunctionForwardVariablesFrom, List) {
10 Scheduler scheduler;
11 TestWithScope setup;
12
13 // Defines a template and copy the two x and y values out.
14 TestParseInput input(
15 "template(\"a\") {\n"
16 " forward_variables_from(invoker, [\"x\", \"y\"])\n"
17 " print(\"$target_name, $x, $y\")\n"
18 "}\n"
19 "a(\"target\") {\n"
20 " x = 1\n"
21 " y = 2\n"
22 "}\n");
23
24 ASSERT_FALSE(input.has_error());
25
26 Err err;
27 input.parsed()->Execute(setup.scope(), &err);
28 ASSERT_FALSE(err.has_error()) << err.message();
29
30 EXPECT_EQ("target, 1, 2\n", setup.print_output());
31 setup.print_output().clear();
32 }
33
34 TEST(FunctionForwardVariablesFrom, Star) {
35 Scheduler scheduler;
36 TestWithScope setup;
37
38 // Defines a template and copy the two x and y values out.
39 TestParseInput input(
40 "template(\"a\") {\n"
41 " forward_variables_from(invoker, \"*\")\n"
42 " print(\"$target_name, $x, $y\")\n"
43 "}\n"
44 "a(\"target\") {\n"
45 " x = 1\n"
46 " y = 2\n"
47 "}\n");
48
49 ASSERT_FALSE(input.has_error());
50
51 Err err;
52 input.parsed()->Execute(setup.scope(), &err);
53 ASSERT_FALSE(err.has_error()) << err.message();
54
55 EXPECT_EQ("target, 1, 2\n", setup.print_output());
56 setup.print_output().clear();
57 }
Dirk Pranke 2015/08/03 19:07:20 Maybe add a test where one of the values isn't def
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698