| 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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
| 6 #include "tools/gn/input_file.h" | 6 #include "tools/gn/input_file.h" |
| 7 #include "tools/gn/parse_tree.h" | 7 #include "tools/gn/parse_tree.h" |
| 8 #include "tools/gn/scope.h" | 8 #include "tools/gn/scope.h" |
| 9 #include "tools/gn/test_with_scope.h" | 9 #include "tools/gn/test_with_scope.h" |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 new IdentifierNode(member_token)); | 24 new IdentifierNode(member_token)); |
| 25 accessor.set_member(member_identifier.Pass()); | 25 accessor.set_member(member_identifier.Pass()); |
| 26 | 26 |
| 27 // The access should fail because a is not defined. | 27 // The access should fail because a is not defined. |
| 28 Err err; | 28 Err err; |
| 29 Value result = accessor.Execute(setup.scope(), &err); | 29 Value result = accessor.Execute(setup.scope(), &err); |
| 30 EXPECT_TRUE(err.has_error()); | 30 EXPECT_TRUE(err.has_error()); |
| 31 EXPECT_EQ(Value::NONE, result.type()); | 31 EXPECT_EQ(Value::NONE, result.type()); |
| 32 | 32 |
| 33 // Define a as a Scope. It should still fail because b isn't defined. | 33 // Define a as a Scope. It should still fail because b isn't defined. |
| 34 Scope a_scope(setup.scope()); | |
| 35 err = Err(); | 34 err = Err(); |
| 36 setup.scope()->SetValue("a", Value(NULL, &a_scope), NULL); | 35 setup.scope()->SetValue("a", |
| 36 Value(NULL, scoped_ptr<Scope>(new Scope(setup.scope()))), NULL); |
| 37 result = accessor.Execute(setup.scope(), &err); | 37 result = accessor.Execute(setup.scope(), &err); |
| 38 EXPECT_TRUE(err.has_error()); | 38 EXPECT_TRUE(err.has_error()); |
| 39 EXPECT_EQ(Value::NONE, result.type()); | 39 EXPECT_EQ(Value::NONE, result.type()); |
| 40 | 40 |
| 41 // Define b, accessor should succeed now. | 41 // Define b, accessor should succeed now. |
| 42 const int64 kBValue = 42; | 42 const int64 kBValue = 42; |
| 43 err = Err(); | 43 err = Err(); |
| 44 a_scope.SetValue("b", Value(NULL, kBValue), NULL); | 44 setup.scope()->GetMutableValue("a", false)->scope_value()->SetValue( |
| 45 "b", Value(NULL, kBValue), NULL); |
| 45 result = accessor.Execute(setup.scope(), &err); | 46 result = accessor.Execute(setup.scope(), &err); |
| 46 EXPECT_FALSE(err.has_error()); | 47 EXPECT_FALSE(err.has_error()); |
| 47 ASSERT_EQ(Value::INTEGER, result.type()); | 48 ASSERT_EQ(Value::INTEGER, result.type()); |
| 48 EXPECT_EQ(kBValue, result.int_value()); | 49 EXPECT_EQ(kBValue, result.int_value()); |
| 49 } | 50 } |
| OLD | NEW |