| Index: tools/gn/parser_unittest.cc
|
| diff --git a/tools/gn/parser_unittest.cc b/tools/gn/parser_unittest.cc
|
| index 39703737a2a8af393cf6b4a60b7c4d07640616d0..6caeeb4079463bbbd162c9ed07c86feb5cb30762 100644
|
| --- a/tools/gn/parser_unittest.cc
|
| +++ b/tools/gn/parser_unittest.cc
|
| @@ -246,8 +246,14 @@ TEST(Parser, Accessor) {
|
| " b\n"
|
| " IDENTIFIER(c)\n"
|
| " LITERAL(2)\n");
|
| + DoParserPrintTest("a.b = 5",
|
| + "BLOCK\n"
|
| + " BINARY(=)\n"
|
| + " ACCESSOR\n"
|
| + " a\n"
|
| + " IDENTIFIER(b)\n"
|
| + " LITERAL(5)\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).
|
|
|
| // Error at the bad dot in the RHS, not the + operator (crbug.com/472038).
|
| DoParserErrorTest("foo(a + b.c.d)", 1, 10);
|
| @@ -701,11 +707,38 @@ TEST(Parser, ConditionNoBracesElseIf) {
|
| // a function with an associated block, or a standalone function with a
|
| // freestanding block.
|
| TEST(Parser, StandaloneBlock) {
|
| + // The error is reported at the end of the block when nothing is done
|
| + // with it. If we had said "a = { ..." then it would have been OK.
|
| DoParserErrorTest(
|
| "if (true) {\n"
|
| "}\n"
|
| "{\n"
|
| " assert(false)\n"
|
| "}\n",
|
| - 3, 1);
|
| + 5, 1);
|
| +}
|
| +
|
| +TEST(Parser, BlockValues) {
|
| + const char* input =
|
| + "print({a = 1 b = 2}, 3)\n"
|
| + "a = { b = \"asd\" }";
|
| + const char* expected =
|
| + "BLOCK\n"
|
| + " FUNCTION(print)\n"
|
| + " LIST\n"
|
| + " BLOCK\n"
|
| + " BINARY(=)\n"
|
| + " IDENTIFIER(a)\n"
|
| + " LITERAL(1)\n"
|
| + " BINARY(=)\n"
|
| + " IDENTIFIER(b)\n"
|
| + " LITERAL(2)\n"
|
| + " LITERAL(3)\n"
|
| + " BINARY(=)\n"
|
| + " IDENTIFIER(a)\n"
|
| + " BLOCK\n"
|
| + " BINARY(=)\n"
|
| + " IDENTIFIER(b)\n"
|
| + " LITERAL(\"asd\")\n";
|
| + DoParserPrintTest(input, expected);
|
| }
|
|
|