OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 #include "tools/gn/input_file.h" | 6 #include "tools/gn/input_file.h" |
7 #include "tools/gn/parse_tree.h" | 7 #include "tools/gn/parse_tree.h" |
8 #include "tools/gn/scope.h" | 8 #include "tools/gn/scope.h" |
9 #include "tools/gn/template.h" | 9 #include "tools/gn/template.h" |
10 #include "tools/gn/test_with_scope.h" | 10 #include "tools/gn/test_with_scope.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 210 |
211 // Root scope should be const from the nested caller's perspective. | 211 // Root scope should be const from the nested caller's perspective. |
212 Scope nested1(static_cast<const Scope*>(setup.scope())); | 212 Scope nested1(static_cast<const Scope*>(setup.scope())); |
213 nested1.SetValue("on_one", Value(&assignment, "on_one"), &assignment); | 213 nested1.SetValue("on_one", Value(&assignment, "on_one"), &assignment); |
214 | 214 |
215 Scope nested2(&nested1); | 215 Scope nested2(&nested1); |
216 nested2.SetValue("on_one", Value(&assignment, "on_two"), &assignment); | 216 nested2.SetValue("on_one", Value(&assignment, "on_two"), &assignment); |
217 nested2.SetValue("on_two", Value(&assignment, "on_two2"), &assignment); | 217 nested2.SetValue("on_two", Value(&assignment, "on_two2"), &assignment); |
218 | 218 |
219 // Making a closure from the root scope. | 219 // Making a closure from the root scope. |
220 scoped_ptr<Scope> result = setup.scope()->MakeClosure(); | 220 std::unique_ptr<Scope> result = setup.scope()->MakeClosure(); |
221 EXPECT_FALSE(result->containing()); // Should have no containing scope. | 221 EXPECT_FALSE(result->containing()); // Should have no containing scope. |
222 EXPECT_TRUE(result->GetValue("on_root")); // Value should be copied. | 222 EXPECT_TRUE(result->GetValue("on_root")); // Value should be copied. |
223 | 223 |
224 // Making a closure from the second nested scope. | 224 // Making a closure from the second nested scope. |
225 result = nested2.MakeClosure(); | 225 result = nested2.MakeClosure(); |
226 EXPECT_EQ(setup.scope(), | 226 EXPECT_EQ(setup.scope(), |
227 result->containing()); // Containing scope should be the root. | 227 result->containing()); // Containing scope should be the root. |
228 EXPECT_TRUE(HasStringValueEqualTo(result.get(), "on_root", "on_root")); | 228 EXPECT_TRUE(HasStringValueEqualTo(result.get(), "on_root", "on_root")); |
229 EXPECT_TRUE(HasStringValueEqualTo(result.get(), "on_one", "on_two")); | 229 EXPECT_TRUE(HasStringValueEqualTo(result.get(), "on_one", "on_two")); |
230 EXPECT_TRUE(HasStringValueEqualTo(result.get(), "on_two", "on_two2")); | 230 EXPECT_TRUE(HasStringValueEqualTo(result.get(), "on_two", "on_two2")); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 | 286 |
287 TEST(Scope, RemovePrivateIdentifiers) { | 287 TEST(Scope, RemovePrivateIdentifiers) { |
288 TestWithScope setup; | 288 TestWithScope setup; |
289 setup.scope()->SetValue("a", Value(nullptr, true), nullptr); | 289 setup.scope()->SetValue("a", Value(nullptr, true), nullptr); |
290 setup.scope()->SetValue("_b", Value(nullptr, true), nullptr); | 290 setup.scope()->SetValue("_b", Value(nullptr, true), nullptr); |
291 | 291 |
292 setup.scope()->RemovePrivateIdentifiers(); | 292 setup.scope()->RemovePrivateIdentifiers(); |
293 EXPECT_TRUE(setup.scope()->GetValue("a")); | 293 EXPECT_TRUE(setup.scope()->GetValue("a")); |
294 EXPECT_FALSE(setup.scope()->GetValue("_b")); | 294 EXPECT_FALSE(setup.scope()->GetValue("_b")); |
295 } | 295 } |
OLD | NEW |