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

Unified Diff: tools/gn/parser_unittest.cc

Issue 207233003: Add "." accessors to GN. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/parser.cc ('k') | tools/gn/scope.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/parser_unittest.cc
diff --git a/tools/gn/parser_unittest.cc b/tools/gn/parser_unittest.cc
index 7ef5ff64fbc9d57966cd0849495a0a9904c7cb16..adb8fdb4be584a989d1b5f1f8bb1f2aaee4937c9 100644
--- a/tools/gn/parser_unittest.cc
+++ b/tools/gn/parser_unittest.cc
@@ -27,6 +27,8 @@ void DoParserPrintTest(const char* input, const char* expected) {
Err err;
scoped_ptr<ParseNode> result = Parser::Parse(tokens, &err);
+ if (!result)
+ err.PrintToStdout();
ASSERT_TRUE(result);
std::ostringstream collector;
@@ -215,15 +217,31 @@ TEST(Parser, Assignment) {
}
TEST(Parser, Accessor) {
- DoParserPrintTest("a=b[2]",
+ // Accessor indexing.
+ DoParserPrintTest("a=b[c+2]",
"BLOCK\n"
" BINARY(=)\n"
" IDENTIFIER(a)\n"
" ACCESSOR\n"
" b\n" // AccessorNode is a bit weird in that it holds
// a Token, not a ParseNode for the base.
- " LITERAL(2)\n");
+ " BINARY(+)\n"
+ " IDENTIFIER(c)\n"
+ " LITERAL(2)\n");
DoParserErrorTest("a = b[1][0]", 1, 5);
+
+ // Member accessors.
+ DoParserPrintTest("a=b.c+2",
+ "BLOCK\n"
+ " BINARY(=)\n"
+ " IDENTIFIER(a)\n"
+ " BINARY(+)\n"
+ " ACCESSOR\n"
+ " b\n"
+ " IDENTIFIER(c)\n"
+ " LITERAL(2)\n");
+ DoParserErrorTest("a = b.c.d", 1, 6); // Can't nest accessors (currently).
+ DoParserErrorTest("a.b = 5", 1, 1); // Can't assign to accessors (currently).
}
TEST(Parser, Condition) {
« no previous file with comments | « tools/gn/parser.cc ('k') | tools/gn/scope.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698