// 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/template.h" #include "tools/gn/test_with_scope.h" namespace { bool HasStringValueEqualTo(const Scope* scope, const char* name, const char* expected_value) { const Value* value = scope->GetValue(name); if (!value) return false; if (value->type() != Value::STRING) return false; return value->string_value() == expected_value; } } // namespace 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, 1), Token::STRING, "\"hello\""); LiteralNode assignment; assignment.set_value(assignment_token); // Add some values to the scope. Value old_value(&assignment, "hello"); setup.scope()->SetValue("v", old_value, &assignment); base::StringPiece private_var_name("_private"); setup.scope()->SetValue(private_var_name, old_value, &assignment); // Add some templates to the scope. FunctionCallNode templ_definition; scoped_refptr