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

Side by Side Diff: tools/gn/scope_unittest.cc

Issue 1869503004: Convert //tools to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, change iwyu fixes for converted directories to include <memory> Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « tools/gn/scope_per_file_provider.h ('k') | tools/gn/setup.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « tools/gn/scope_per_file_provider.h ('k') | tools/gn/setup.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698