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

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

Issue 2252293003: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 3 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/desc_builder.cc ('k') | tools/gn/json_project_writer.cc » ('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/functions.h" 5 #include "tools/gn/functions.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 30 matching lines...) Expand all
41 std::unique_ptr<ParseNode>(new IdentifierNode(defined_token))); 41 std::unique_ptr<ParseNode>(new IdentifierNode(defined_token)));
42 result = functions::RunDefined(setup.scope(), &function_call, 42 result = functions::RunDefined(setup.scope(), &function_call,
43 &args_list_identifier_defined, &err); 43 &args_list_identifier_defined, &err);
44 ASSERT_EQ(Value::BOOLEAN, result.type()); 44 ASSERT_EQ(Value::BOOLEAN, result.type());
45 EXPECT_TRUE(result.boolean_value()); 45 EXPECT_TRUE(result.boolean_value());
46 46
47 // Should also work by passing an accessor node so you can do 47 // Should also work by passing an accessor node so you can do
48 // "defined(def.foo)" to see if foo is defined on the def scope. 48 // "defined(def.foo)" to see if foo is defined on the def scope.
49 std::unique_ptr<AccessorNode> undef_accessor(new AccessorNode); 49 std::unique_ptr<AccessorNode> undef_accessor(new AccessorNode);
50 undef_accessor->set_base(defined_token); 50 undef_accessor->set_base(defined_token);
51 undef_accessor->set_member( 51 undef_accessor->set_member(base::MakeUnique<IdentifierNode>(undefined_token));
52 base::WrapUnique(new IdentifierNode(undefined_token)));
53 ListNode args_list_accessor_defined; 52 ListNode args_list_accessor_defined;
54 args_list_accessor_defined.append_item(std::move(undef_accessor)); 53 args_list_accessor_defined.append_item(std::move(undef_accessor));
55 result = functions::RunDefined(setup.scope(), &function_call, 54 result = functions::RunDefined(setup.scope(), &function_call,
56 &args_list_accessor_defined, &err); 55 &args_list_accessor_defined, &err);
57 ASSERT_EQ(Value::BOOLEAN, result.type()); 56 ASSERT_EQ(Value::BOOLEAN, result.type());
58 EXPECT_FALSE(result.boolean_value()); 57 EXPECT_FALSE(result.boolean_value());
59 } 58 }
60 59
61 // Tests that an error is thrown when a {} is supplied to a function that 60 // Tests that an error is thrown when a {} is supplied to a function that
62 // doesn't take one. 61 // doesn't take one.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 input.parsed()->Execute(setup.scope(), &err); 118 input.parsed()->Execute(setup.scope(), &err);
120 ASSERT_FALSE(err.has_error()) << err.message(); 119 ASSERT_FALSE(err.has_error()) << err.message();
121 120
122 EXPECT_EQ( 121 EXPECT_EQ(
123 "empty = [[]] [[], [], []]\n" 122 "empty = [[]] [[], [], []]\n"
124 "one = [[1]] [[1], []]\n" 123 "one = [[1]] [[1], []]\n"
125 "many = [[1, 2, 3, 4, 5], [6, 7, 8, 9]]\n" 124 "many = [[1, 2, 3, 4, 5], [6, 7, 8, 9]]\n"
126 "rounding = [[1, 2], [3, 4], [5], [6]]\n", 125 "rounding = [[1, 2], [3, 4], [5], [6]]\n",
127 setup.print_output()); 126 setup.print_output());
128 } 127 }
OLDNEW
« no previous file with comments | « tools/gn/desc_builder.cc ('k') | tools/gn/json_project_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698