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

Unified Diff: tools/gn/parser_unittest.cc

Issue 2187523003: Allow creation and modification of scopes in GN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 4 years, 4 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 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);
}
« 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