This source file includes following definitions.
- TEST
#include "testing/gtest/include/gtest/gtest.h"
#include "tools/gn/input_file.h"
#include "tools/gn/parse_tree.h"
#include "tools/gn/scope.h"
#include "tools/gn/test_with_scope.h"
TEST(ParseTree, Accessor) {
TestWithScope setup;
InputFile input_file(SourceFile("//foo"));
Token base_token(Location(&input_file, 1, 1), Token::IDENTIFIER, "a");
Token member_token(Location(&input_file, 1, 1), Token::IDENTIFIER, "b");
AccessorNode accessor;
accessor.set_base(base_token);
scoped_ptr<IdentifierNode> member_identifier(
new IdentifierNode(member_token));
accessor.set_member(member_identifier.Pass());
Err err;
Value result = accessor.Execute(setup.scope(), &err);
EXPECT_TRUE(err.has_error());
EXPECT_EQ(Value::NONE, result.type());
Scope a_scope(setup.scope());
err = Err();
setup.scope()->SetValue("a", Value(NULL, &a_scope), NULL);
result = accessor.Execute(setup.scope(), &err);
EXPECT_TRUE(err.has_error());
EXPECT_EQ(Value::NONE, result.type());
const int64 kBValue = 42;
err = Err();
a_scope.SetValue("b", Value(NULL, kBValue), NULL);
result = accessor.Execute(setup.scope(), &err);
EXPECT_FALSE(err.has_error());
ASSERT_EQ(Value::INTEGER, result.type());
EXPECT_EQ(kBValue, result.int_value());
}