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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
Index: tools/gn/function_forward_variables_from_unittest.cc
diff --git a/tools/gn/function_forward_variables_from_unittest.cc b/tools/gn/function_forward_variables_from_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9072eba9aa125b9fd369ddd930df75a5cae9d056
--- /dev/null
+++ b/tools/gn/function_forward_variables_from_unittest.cc
@@ -0,0 +1,57 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "testing/gtest/include/gtest/gtest.h"
+#include "tools/gn/scheduler.h"
+#include "tools/gn/test_with_scope.h"
+
+TEST(FunctionForwardVariablesFrom, List) {
+ Scheduler scheduler;
+ TestWithScope setup;
+
+ // Defines a template and copy the two x and y values out.
+ TestParseInput input(
+ "template(\"a\") {\n"
+ " forward_variables_from(invoker, [\"x\", \"y\"])\n"
+ " print(\"$target_name, $x, $y\")\n"
+ "}\n"
+ "a(\"target\") {\n"
+ " x = 1\n"
+ " y = 2\n"
+ "}\n");
+
+ ASSERT_FALSE(input.has_error());
+
+ Err err;
+ input.parsed()->Execute(setup.scope(), &err);
+ ASSERT_FALSE(err.has_error()) << err.message();
+
+ EXPECT_EQ("target, 1, 2\n", setup.print_output());
+ setup.print_output().clear();
+}
+
+TEST(FunctionForwardVariablesFrom, Star) {
+ Scheduler scheduler;
+ TestWithScope setup;
+
+ // Defines a template and copy the two x and y values out.
+ TestParseInput input(
+ "template(\"a\") {\n"
+ " forward_variables_from(invoker, \"*\")\n"
+ " print(\"$target_name, $x, $y\")\n"
+ "}\n"
+ "a(\"target\") {\n"
+ " x = 1\n"
+ " y = 2\n"
+ "}\n");
+
+ ASSERT_FALSE(input.has_error());
+
+ Err err;
+ input.parsed()->Execute(setup.scope(), &err);
+ ASSERT_FALSE(err.has_error()) << err.message();
+
+ EXPECT_EQ("target, 1, 2\n", setup.print_output());
+ setup.print_output().clear();
+}
Dirk Pranke 2015/08/03 19:07:20 Maybe add a test where one of the values isn't def

Powered by Google App Engine
This is Rietveld 408576698