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

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

Issue 1544333002: Convert Pass()→std::move() in //tools (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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.cc ('k') | tools/gn/input_conversion.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"
6
7 #include <utility>
8
5 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
6 #include "tools/gn/functions.h"
7 #include "tools/gn/parse_tree.h" 10 #include "tools/gn/parse_tree.h"
8 #include "tools/gn/test_with_scope.h" 11 #include "tools/gn/test_with_scope.h"
9 #include "tools/gn/value.h" 12 #include "tools/gn/value.h"
10 13
11 TEST(Functions, Defined) { 14 TEST(Functions, Defined) {
12 TestWithScope setup; 15 TestWithScope setup;
13 16
14 FunctionCallNode function_call; 17 FunctionCallNode function_call;
15 Err err; 18 Err err;
16 19
(...skipping 23 matching lines...) Expand all
40 ASSERT_EQ(Value::BOOLEAN, result.type()); 43 ASSERT_EQ(Value::BOOLEAN, result.type());
41 EXPECT_TRUE(result.boolean_value()); 44 EXPECT_TRUE(result.boolean_value());
42 45
43 // Should also work by passing an accessor node so you can do 46 // Should also work by passing an accessor node so you can do
44 // "defined(def.foo)" to see if foo is defined on the def scope. 47 // "defined(def.foo)" to see if foo is defined on the def scope.
45 scoped_ptr<AccessorNode> undef_accessor(new AccessorNode); 48 scoped_ptr<AccessorNode> undef_accessor(new AccessorNode);
46 undef_accessor->set_base(defined_token); 49 undef_accessor->set_base(defined_token);
47 undef_accessor->set_member(scoped_ptr<IdentifierNode>( 50 undef_accessor->set_member(scoped_ptr<IdentifierNode>(
48 new IdentifierNode(undefined_token))); 51 new IdentifierNode(undefined_token)));
49 ListNode args_list_accessor_defined; 52 ListNode args_list_accessor_defined;
50 args_list_accessor_defined.append_item(undef_accessor.Pass()); 53 args_list_accessor_defined.append_item(std::move(undef_accessor));
51 result = functions::RunDefined(setup.scope(), &function_call, 54 result = functions::RunDefined(setup.scope(), &function_call,
52 &args_list_accessor_defined, &err); 55 &args_list_accessor_defined, &err);
53 ASSERT_EQ(Value::BOOLEAN, result.type()); 56 ASSERT_EQ(Value::BOOLEAN, result.type());
54 EXPECT_FALSE(result.boolean_value()); 57 EXPECT_FALSE(result.boolean_value());
55 } 58 }
56 59
57 // 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
58 // doesn't take one. 61 // doesn't take one.
59 TEST(Functions, FunctionsWithBlock) { 62 TEST(Functions, FunctionsWithBlock) {
60 TestWithScope setup; 63 TestWithScope setup;
(...skipping 18 matching lines...) Expand all
79 EXPECT_FALSE(defined_no_scope.has_error()); 82 EXPECT_FALSE(defined_no_scope.has_error());
80 result = defined_no_scope.parsed()->Execute(setup.scope(), &err); 83 result = defined_no_scope.parsed()->Execute(setup.scope(), &err);
81 EXPECT_FALSE(err.has_error()); 84 EXPECT_FALSE(err.has_error());
82 85
83 // A block to defined should fail. 86 // A block to defined should fail.
84 TestParseInput defined_with_scope("defined(foo) {}"); 87 TestParseInput defined_with_scope("defined(foo) {}");
85 EXPECT_FALSE(defined_with_scope.has_error()); 88 EXPECT_FALSE(defined_with_scope.has_error());
86 result = defined_with_scope.parsed()->Execute(setup.scope(), &err); 89 result = defined_with_scope.parsed()->Execute(setup.scope(), &err);
87 EXPECT_TRUE(err.has_error()); 90 EXPECT_TRUE(err.has_error());
88 } 91 }
OLDNEW
« no previous file with comments | « tools/gn/functions.cc ('k') | tools/gn/input_conversion.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698