From 1c5d9df8d1af0f266923edba8fcb367a51a03d26 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Fri, 6 Sep 2013 07:54:20 +0000 Subject: clang-format: Fix comment formatting bugs in nested blocks. This fixes two issues: 1) The indent of a line comment was not adapted to the subsequent statement as it would be outside of a nested block. 2) A missing DryRun flag caused actualy breaks to be inserted in overly long comments while trying to come up with the best line breaking decisions. llvm-svn: 190123 --- clang/unittests/Format/FormatTest.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'clang/unittests/Format/FormatTest.cpp') diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 6d953eb3018..3eaa69a8b6c 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -564,6 +564,17 @@ TEST_F(FormatTest, FormatsSwitchStatement) { " }\n" "#undef OPERATION_CASE\n" "}"); + verifyFormat("DEBUG({\n" + " switch (x) {\n" + " case A:\n" + " f();\n" + " break;\n" + " // On B:\n" + " case B:\n" + " g();\n" + " break;\n" + " }\n" + "});"); } TEST_F(FormatTest, FormatsLabels) { @@ -2241,6 +2252,24 @@ TEST_F(FormatTest, LayoutNestedBlocks) { " for (int i = 0; i < 10; ++i)\n" " return;\n" "}"); + verifyFormat("call(parameter, {\n" + " something();\n" + " // Comment using all columns.\n" + " somethingelse();\n" + "});", + getLLVMStyleWithColumns(40)); + EXPECT_EQ("call(parameter, {\n" + " something();\n" + " // Comment too\n" + " // looooooooooong.\n" + " somethingElse();\n" + "});", + format("call(parameter, {\n" + " something();\n" + " // Comment too looooooooooong.\n" + " somethingElse();\n" + "});", + getLLVMStyleWithColumns(29))); } TEST_F(FormatTest, PutEmptyBlocksIntoOneLine) { -- cgit v1.2.3