OLD | NEW |
---|---|
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 Loading... | |
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 } |
OLD | NEW |