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

Side by Side Diff: tools/gn/parser_unittest.cc

Issue 595753002: gn: handle continued suffix comments (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn-append-comment
Patch Set: Created 6 years, 3 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 unified diff | Download patch
« no previous file with comments | « tools/gn/parser.cc ('k') | tools/gn/tokenizer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <iostream> 5 #include <iostream>
6 #include <sstream> 6 #include <sstream>
7 7
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "tools/gn/input_file.h" 9 #include "tools/gn/input_file.h"
10 #include "tools/gn/parser.h" 10 #include "tools/gn/parser.h"
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 " BLOCK\n" 576 " BLOCK\n"
577 " BINARY(=)\n" 577 " BINARY(=)\n"
578 " IDENTIFIER(sources)\n" 578 " IDENTIFIER(sources)\n"
579 " LIST\n" 579 " LIST\n"
580 " LITERAL(\"a\")\n" 580 " LITERAL(\"a\")\n"
581 " LITERAL(\"b\")\n" 581 " LITERAL(\"b\")\n"
582 " +SUFFIX_COMMENT(\"# Comment\")\n"; 582 " +SUFFIX_COMMENT(\"# Comment\")\n";
583 DoParserPrintTest(input, expected); 583 DoParserPrintTest(input, expected);
584 } 584 }
585 585
586 TEST(Parser, CommentsSuffixMultiple) {
587 const char* input =
588 "executable(\"wee\") {\n"
589 " sources = [\n"
590 " \"a\", # This is a comment,\n"
591 " # and some more,\n"
592 " # then the end.\n"
brettw 2014/09/23 21:49:09 What about this code: sources = [ "a" ] # This s
scottmg 2014/09/23 22:41:01 Yeah, it does treat it as a continuation. I notice
593 " ]\n"
594 "}\n";
595 const char* expected =
596 "BLOCK\n"
597 " FUNCTION(executable)\n"
598 " LIST\n"
599 " LITERAL(\"wee\")\n"
600 " BLOCK\n"
601 " BINARY(=)\n"
602 " IDENTIFIER(sources)\n"
603 " LIST\n"
604 " LITERAL(\"a\")\n"
605 " +SUFFIX_COMMENT(\"# This is a comment,\")\n"
606 " +SUFFIX_COMMENT(\"# and some more,\")\n"
607 " +SUFFIX_COMMENT(\"# then the end.\")\n";
608 DoParserPrintTest(input, expected);
609 }
610
611
586 TEST(Parser, HangingIf) { 612 TEST(Parser, HangingIf) {
587 DoParserErrorTest("if", 1, 1); 613 DoParserErrorTest("if", 1, 1);
588 } 614 }
589 615
590 TEST(Parser, NegatingList) { 616 TEST(Parser, NegatingList) {
591 DoParserErrorTest("executable(\"wee\") { sources =- [ \"foo.cc\" ] }", 1, 30); 617 DoParserErrorTest("executable(\"wee\") { sources =- [ \"foo.cc\" ] }", 1, 30);
592 } 618 }
OLDNEW
« no previous file with comments | « tools/gn/parser.cc ('k') | tools/gn/tokenizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698