OLD | NEW |
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" |
(...skipping 29 matching lines...) Expand all Loading... |
40 "a", Value(nullptr, std::unique_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", Scope::SEARCH_NESTED, false) |
51 ->scope_value() | 51 ->scope_value() |
52 ->SetValue("b", Value(nullptr, kBValue), nullptr); | 52 ->SetValue("b", Value(nullptr, kBValue), nullptr); |
53 result = accessor.Execute(setup.scope(), &err); | 53 result = accessor.Execute(setup.scope(), &err); |
54 EXPECT_FALSE(err.has_error()); | 54 EXPECT_FALSE(err.has_error()); |
55 ASSERT_EQ(Value::INTEGER, result.type()); | 55 ASSERT_EQ(Value::INTEGER, result.type()); |
56 EXPECT_EQ(kBValue, result.int_value()); | 56 EXPECT_EQ(kBValue, result.int_value()); |
57 } | 57 } |
58 | 58 |
59 TEST(ParseTree, BlockUnusedVars) { | 59 TEST(ParseTree, BlockUnusedVars) { |
60 TestWithScope setup; | 60 TestWithScope setup; |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
OLD | NEW |