Chromium Code Reviews| 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). |
|
scottmg
2014/03/25 05:04:23
This one seems especially odd to not support, but
|
| + DoParserErrorTest("a.b = 5", 1, 1); // Can't assign to accessors (currently). |
| } |
| TEST(Parser, Condition) { |