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

Unified Diff: tools/gn/scope_unittest.cc

Issue 103593006: Allow GN imports to be processed from imports. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/scope.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/scope_unittest.cc
diff --git a/tools/gn/scope_unittest.cc b/tools/gn/scope_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a693957923ee543c04a4dc52b1efd28c52e5d421
--- /dev/null
+++ b/tools/gn/scope_unittest.cc
@@ -0,0 +1,48 @@
+// Copyright (c) 2013 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/input_file.h"
+#include "tools/gn/parse_tree.h"
+#include "tools/gn/scope.h"
+#include "tools/gn/test_with_scope.h"
+
+TEST(Scope, NonRecursiveMergeTo) {
+ TestWithScope setup;
+
+ // Make a pretend parse node with proper tracking that we can blame for the
+ // given value.
+ InputFile input_file(SourceFile("//foo"));
+ Token assignment_token(Location(&input_file, 1, 1), Token::STRING,
+ "\"hello\"");
+ LiteralNode assignment;
+ assignment.set_value(assignment_token);
+
+ Value old_value(&assignment, "hello");
+ setup.scope()->SetValue("v", old_value, &assignment);
+
+ // Detect collisions of values' values.
+ {
+ Scope new_scope(setup.settings());
+ Value new_value(&assignment, "goodbye");
+ new_scope.SetValue("v", new_value, &assignment);
+
+ Err err;
+ EXPECT_FALSE(new_scope.NonRecursiveMergeTo(
+ setup.scope(), &assignment, "error", &err));
+ EXPECT_TRUE(err.has_error());
+ }
+
+ // Don't flag values that technically collide but have the same value.
+ {
+ Scope new_scope(setup.settings());
+ Value new_value(&assignment, "hello");
+ new_scope.SetValue("v", new_value, &assignment);
+
+ Err err;
+ EXPECT_TRUE(new_scope.NonRecursiveMergeTo(
+ setup.scope(), &assignment, "error", &err));
+ EXPECT_FALSE(err.has_error());
+ }
+}
« no previous file with comments | « tools/gn/scope.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698