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

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

Issue 588813002: gn: beginnings of format command (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: handle line comments at eof 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/scope_unittest.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 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 " BINARY(||)\n" 484 " BINARY(||)\n"
485 " BINARY(&&)\n" 485 " BINARY(&&)\n"
486 " BINARY(+)\n" 486 " BINARY(+)\n"
487 " IDENTIFIER(b)\n" 487 " IDENTIFIER(b)\n"
488 " IDENTIFIER(c)\n" 488 " IDENTIFIER(c)\n"
489 " IDENTIFIER(d)\n" 489 " IDENTIFIER(d)\n"
490 " IDENTIFIER(e)\n"; 490 " IDENTIFIER(e)\n";
491 DoParserPrintTest(input, expected); 491 DoParserPrintTest(input, expected);
492 } 492 }
493 493
494 TEST(Parser, CommentsStandalone) {
495 const char* input = "# Toplevel comment.\n\nexecutable(\"wee\") {}\n";
496 const char* expected =
497 "BLOCK\n"
498 " +BEFORE_COMMENT(\"# Toplevel comment.\")\n"
499 " FUNCTION(executable)\n"
500 " LIST\n"
501 " LITERAL(\"wee\")\n"
502 " BLOCK\n";
503 DoParserPrintTest(input, expected);
504 }
505
506 TEST(Parser, CommentsStandaloneEof) {
507 const char* input = "executable(\"wee\") {}\n# EOF comment.\n";
508 const char* expected =
509 "BLOCK\n"
510 " +AFTER_COMMENT(\"# EOF comment.\")\n"
511 " FUNCTION(executable)\n"
512 " LIST\n"
513 " LITERAL(\"wee\")\n"
514 " BLOCK\n";
515 DoParserPrintTest(input, expected);
516 }
517
518 /* TODO(scottmg): Not implemented yet.
519 TEST(Parser, CommentsSuffix) {
520 const char* input = "executable(\"wee\") { # This is some stuff.\n"
521 "sources = [ \"a.cc\"\n"
522 "] }";
523 const char* expected =
524 "BLOCK\n"
525 " FUNCTION(executable)\n"
526 " LIST\n"
527 " LITERAL(\"wee\")\n"
528 " +SUFFIX_COMMENT(\"# This is some stuff.\")\n"
529 " BLOCK\n"
530 " BINARY(=)\n"
531 " IDENTIFIER(sources)\n"
532 " LIST\n"
533 " LITERAL(\"a.cc\")\n"
534 " +SUFFIX_COMMENT(\"# And another comment here.\")\n";
535 DoParserPrintTest(input, expected);
536 }
537 */
538
494 TEST(Parser, HangingIf) { 539 TEST(Parser, HangingIf) {
495 DoParserErrorTest("if", 1, 1); 540 DoParserErrorTest("if", 1, 1);
496 } 541 }
497 542
498 TEST(Parser, NegatingList) { 543 TEST(Parser, NegatingList) {
499 DoParserErrorTest("executable(\"wee\") { sources =- [ \"foo.cc\" ] }", 1, 30); 544 DoParserErrorTest("executable(\"wee\") { sources =- [ \"foo.cc\" ] }", 1, 30);
500 } 545 }
OLDNEW
« no previous file with comments | « tools/gn/parser.cc ('k') | tools/gn/scope_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698