Lines Matching refs:scope
8 #include "tools/gn/scope.h"
13 bool HasStringValueEqualTo(const Scope* scope,
16 const Value* value = scope->GetValue(name);
26 TEST(Scope, NonRecursiveMergeTo) {
38 setup.scope()->SetValue("v", old_value, &assignment);
40 setup.scope()->SetValue(private_var_name, old_value, &assignment);
44 Scope new_scope(setup.settings());
49 EXPECT_FALSE(setup.scope()->NonRecursiveMergeTo(
50 &new_scope, Scope::MergeOptions(),
57 Scope new_scope(setup.settings());
62 Scope::MergeOptions options;
64 EXPECT_TRUE(setup.scope()->NonRecursiveMergeTo(
75 Scope new_scope(setup.settings());
80 Scope::MergeOptions options;
82 EXPECT_TRUE(setup.scope()->NonRecursiveMergeTo(
89 Scope new_scope(setup.settings());
92 EXPECT_TRUE(setup.scope()->NonRecursiveMergeTo(
93 &new_scope, Scope::MergeOptions(), &assignment, "error", &err));
100 Scope new_scope(setup.settings());
103 Scope::MergeOptions options;
105 EXPECT_TRUE(setup.scope()->NonRecursiveMergeTo(
113 Scope new_scope(setup.settings());
116 Scope::MergeOptions options;
117 EXPECT_TRUE(setup.scope()->NonRecursiveMergeTo(
126 Scope new_scope(setup.settings());
129 Scope::MergeOptions options;
131 EXPECT_TRUE(setup.scope()->NonRecursiveMergeTo(
139 TEST(Scope, MakeClosure) {
150 setup.scope()->SetValue("on_root", Value(&assignment, "on_root"),
153 // Root scope should be const from the nested caller's perspective.
154 Scope nested1(static_cast<const Scope*>(setup.scope()));
157 Scope nested2(&nested1);
161 // Making a closure from the root scope.
162 scoped_ptr<Scope> result = setup.scope()->MakeClosure();
163 EXPECT_FALSE(result->containing()); // Should have no containing scope.
166 // Making a closure from the second nested scope.
168 EXPECT_EQ(setup.scope(),
169 result->containing()); // Containing scope should be the root.
175 TEST(Scope, GetMutableValue) {
192 // Create a root scope with one value.
193 Scope root_scope(setup.settings());
196 // Create a first nested scope with a different value.
197 const Scope* const_root_scope = &root_scope;
198 Scope mutable_scope1(const_root_scope);
201 // Create a second nested scope with a different value.
202 Scope mutable_scope2(&mutable_scope1);
205 // Check getting root scope values.
209 // Test reading a value from scope 1.
223 // Test reading a value from scope 2.
229 TEST(Scope, RemovePrivateIdentifiers) {
231 setup.scope()->SetValue("a", Value(NULL, true), NULL);
232 setup.scope()->SetValue("_b", Value(NULL, true), NULL);
234 setup.scope()->RemovePrivateIdentifiers();
235 EXPECT_TRUE(setup.scope()->GetValue("a"));
236 EXPECT_FALSE(setup.scope()->GetValue("_b"));