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

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

Issue 656093004: Use scoped_ptr::Pass instead of scoped_ptr::PassAs<T>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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/functions_unittest.cc ('k') | tools/gn/parser.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 (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/operators.h" 6 #include "tools/gn/operators.h"
7 #include "tools/gn/parse_tree.h" 7 #include "tools/gn/parse_tree.h"
8 #include "tools/gn/pattern.h" 8 #include "tools/gn/pattern.h"
9 #include "tools/gn/test_with_scope.h" 9 #include "tools/gn/test_with_scope.h"
10 10
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 node.set_left(scoped_ptr<ParseNode>(new IdentifierNode(identifier_token))); 52 node.set_left(scoped_ptr<ParseNode>(new IdentifierNode(identifier_token)));
53 53
54 // Set up the filter on the scope to remove everything ending with "rm" 54 // Set up the filter on the scope to remove everything ending with "rm"
55 scoped_ptr<PatternList> pattern_list(new PatternList); 55 scoped_ptr<PatternList> pattern_list(new PatternList);
56 pattern_list->Append(Pattern("*rm")); 56 pattern_list->Append(Pattern("*rm"));
57 setup.scope()->set_sources_assignment_filter(pattern_list.Pass()); 57 setup.scope()->set_sources_assignment_filter(pattern_list.Pass());
58 58
59 // Append an integer. 59 // Append an integer.
60 const char integer_value[] = "5"; 60 const char integer_value[] = "5";
61 Token integer(Location(), Token::INTEGER, integer_value); 61 Token integer(Location(), Token::INTEGER, integer_value);
62 node.set_right(ListWithLiteral(integer).PassAs<ParseNode>()); 62 node.set_right(ListWithLiteral(integer));
63 node.Execute(setup.scope(), &err); 63 node.Execute(setup.scope(), &err);
64 EXPECT_FALSE(err.has_error()); 64 EXPECT_FALSE(err.has_error());
65 65
66 // Append a string that doesn't match the pattern, it should get appended. 66 // Append a string that doesn't match the pattern, it should get appended.
67 const char string_1_value[] = "\"good\""; 67 const char string_1_value[] = "\"good\"";
68 Token string_1(Location(), Token::STRING, string_1_value); 68 Token string_1(Location(), Token::STRING, string_1_value);
69 node.set_right(ListWithLiteral(string_1).PassAs<ParseNode>()); 69 node.set_right(ListWithLiteral(string_1));
70 node.Execute(setup.scope(), &err); 70 node.Execute(setup.scope(), &err);
71 EXPECT_FALSE(err.has_error()); 71 EXPECT_FALSE(err.has_error());
72 72
73 // Append a string that does match the pattern, it should be a no-op. 73 // Append a string that does match the pattern, it should be a no-op.
74 const char string_2_value[] = "\"foo-rm\""; 74 const char string_2_value[] = "\"foo-rm\"";
75 Token string_2(Location(), Token::STRING, string_2_value); 75 Token string_2(Location(), Token::STRING, string_2_value);
76 node.set_right(ListWithLiteral(string_2).PassAs<ParseNode>()); 76 node.set_right(ListWithLiteral(string_2));
77 node.Execute(setup.scope(), &err); 77 node.Execute(setup.scope(), &err);
78 EXPECT_FALSE(err.has_error()); 78 EXPECT_FALSE(err.has_error());
79 79
80 // Append a list with the two strings from above. 80 // Append a list with the two strings from above.
81 ListNode list; 81 ListNode list;
82 list.append_item(scoped_ptr<ParseNode>(new LiteralNode(string_1))); 82 list.append_item(scoped_ptr<ParseNode>(new LiteralNode(string_1)));
83 list.append_item(scoped_ptr<ParseNode>(new LiteralNode(string_2))); 83 list.append_item(scoped_ptr<ParseNode>(new LiteralNode(string_2)));
84 ExecuteBinaryOperator(setup.scope(), &node, node.left(), &list, &err); 84 ExecuteBinaryOperator(setup.scope(), &node, node.left(), &list, &err);
85 EXPECT_FALSE(err.has_error()); 85 EXPECT_FALSE(err.has_error());
86 86
(...skipping 24 matching lines...) Expand all
111 node.set_op(op); 111 node.set_op(op);
112 112
113 // Append to the foo variable. 113 // Append to the foo variable.
114 Token identifier_token(Location(), Token::IDENTIFIER, foo); 114 Token identifier_token(Location(), Token::IDENTIFIER, foo);
115 node.set_left(scoped_ptr<ParseNode>(new IdentifierNode(identifier_token))); 115 node.set_left(scoped_ptr<ParseNode>(new IdentifierNode(identifier_token)));
116 116
117 // Append a list with a list, the result should be a nested list. 117 // Append a list with a list, the result should be a nested list.
118 scoped_ptr<ListNode> outer_list(new ListNode); 118 scoped_ptr<ListNode> outer_list(new ListNode);
119 const char twelve_str[] = "12"; 119 const char twelve_str[] = "12";
120 Token twelve(Location(), Token::INTEGER, twelve_str); 120 Token twelve(Location(), Token::INTEGER, twelve_str);
121 outer_list->append_item(ListWithLiteral(twelve).PassAs<ParseNode>()); 121 outer_list->append_item(ListWithLiteral(twelve));
122 node.set_right(outer_list.PassAs<ParseNode>()); 122 node.set_right(outer_list.Pass());
123 123
124 Value ret = ExecuteBinaryOperator(setup.scope(), &node, node.left(), 124 Value ret = ExecuteBinaryOperator(setup.scope(), &node, node.left(),
125 node.right(), &err); 125 node.right(), &err);
126 EXPECT_FALSE(err.has_error()); 126 EXPECT_FALSE(err.has_error());
127 127
128 // Return from the operator should always be "none", it should update the 128 // Return from the operator should always be "none", it should update the
129 // value only. 129 // value only.
130 EXPECT_EQ(Value::NONE, ret.type()); 130 EXPECT_EQ(Value::NONE, ret.type());
131 131
132 // The value should be updated with "[ [ 12 ] ]" 132 // The value should be updated with "[ [ 12 ] ]"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 194
195 // Set right as foo, but don't define a value for it. 195 // Set right as foo, but don't define a value for it.
196 const char foo[] = "foo"; 196 const char foo[] = "foo";
197 Token identifier_token(Location(), Token::IDENTIFIER, foo); 197 Token identifier_token(Location(), Token::IDENTIFIER, foo);
198 node.set_right(scoped_ptr<ParseNode>(new IdentifierNode(identifier_token))); 198 node.set_right(scoped_ptr<ParseNode>(new IdentifierNode(identifier_token)));
199 199
200 Value ret = ExecuteBinaryOperator(setup.scope(), &node, node.left(), 200 Value ret = ExecuteBinaryOperator(setup.scope(), &node, node.left(),
201 node.right(), &err); 201 node.right(), &err);
202 EXPECT_FALSE(err.has_error()); 202 EXPECT_FALSE(err.has_error());
203 } 203 }
OLDNEW
« no previous file with comments | « tools/gn/functions_unittest.cc ('k') | tools/gn/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698