OLD | NEW |
---|---|
(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
| |
OLD | NEW |