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

Side by Side Diff: tools/gn/parse_tree_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/parse_tree.h ('k') | tools/gn/parser.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "tools/gn/parse_tree.h" 5 #include "tools/gn/parse_tree.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "tools/gn/input_file.h" 11 #include "tools/gn/input_file.h"
12 #include "tools/gn/scope.h" 12 #include "tools/gn/scope.h"
13 #include "tools/gn/test_with_scope.h" 13 #include "tools/gn/test_with_scope.h"
14 14
15 TEST(ParseTree, Accessor) { 15 TEST(ParseTree, Accessor) {
16 TestWithScope setup; 16 TestWithScope setup;
17 17
18 // Make a pretend parse node with proper tracking that we can blame for the 18 // Make a pretend parse node with proper tracking that we can blame for the
19 // given value. 19 // given value.
20 InputFile input_file(SourceFile("//foo")); 20 InputFile input_file(SourceFile("//foo"));
21 Token base_token(Location(&input_file, 1, 1, 1), Token::IDENTIFIER, "a"); 21 Token base_token(Location(&input_file, 1, 1, 1), Token::IDENTIFIER, "a");
22 Token member_token(Location(&input_file, 1, 1, 1), Token::IDENTIFIER, "b"); 22 Token member_token(Location(&input_file, 1, 1, 1), Token::IDENTIFIER, "b");
23 23
24 AccessorNode accessor; 24 AccessorNode accessor;
25 accessor.set_base(base_token); 25 accessor.set_base(base_token);
26 26
27 scoped_ptr<IdentifierNode> member_identifier( 27 std::unique_ptr<IdentifierNode> member_identifier(
28 new IdentifierNode(member_token)); 28 new IdentifierNode(member_token));
29 accessor.set_member(std::move(member_identifier)); 29 accessor.set_member(std::move(member_identifier));
30 30
31 // The access should fail because a is not defined. 31 // The access should fail because a is not defined.
32 Err err; 32 Err err;
33 Value result = accessor.Execute(setup.scope(), &err); 33 Value result = accessor.Execute(setup.scope(), &err);
34 EXPECT_TRUE(err.has_error()); 34 EXPECT_TRUE(err.has_error());
35 EXPECT_EQ(Value::NONE, result.type()); 35 EXPECT_EQ(Value::NONE, result.type());
36 36
37 // Define a as a Scope. It should still fail because b isn't defined. 37 // Define a as a Scope. It should still fail because b isn't defined.
38 err = Err(); 38 err = Err();
39 setup.scope()->SetValue( 39 setup.scope()->SetValue(
40 "a", Value(nullptr, scoped_ptr<Scope>(new Scope(setup.scope()))), 40 "a", Value(nullptr, std::unique_ptr<Scope>(new Scope(setup.scope()))),
41 nullptr); 41 nullptr);
42 result = accessor.Execute(setup.scope(), &err); 42 result = accessor.Execute(setup.scope(), &err);
43 EXPECT_TRUE(err.has_error()); 43 EXPECT_TRUE(err.has_error());
44 EXPECT_EQ(Value::NONE, result.type()); 44 EXPECT_EQ(Value::NONE, result.type());
45 45
46 // Define b, accessor should succeed now. 46 // Define b, accessor should succeed now.
47 const int64_t kBValue = 42; 47 const int64_t kBValue = 42;
48 err = Err(); 48 err = Err();
49 setup.scope() 49 setup.scope()
50 ->GetMutableValue("a", false) 50 ->GetMutableValue("a", false)
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 for (auto s : kBad) { 245 for (auto s : kBad) {
246 TestParseInput input(std::string("x = ") + s); 246 TestParseInput input(std::string("x = ") + s);
247 EXPECT_FALSE(input.has_error()); 247 EXPECT_FALSE(input.has_error());
248 248
249 TestWithScope setup; 249 TestWithScope setup;
250 Err err; 250 Err err;
251 input.parsed()->Execute(setup.scope(), &err); 251 input.parsed()->Execute(setup.scope(), &err);
252 EXPECT_TRUE(err.has_error()); 252 EXPECT_TRUE(err.has_error());
253 } 253 }
254 } 254 }
OLDNEW
« no previous file with comments | « tools/gn/parse_tree.h ('k') | tools/gn/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698