diff options
| author | Daniel Jasper <djasper@google.com> | 2012-12-05 14:57:28 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2012-12-05 14:57:28 +0000 |
| commit | aa1c920db85e7ac07d09b80eedc66bae7e358f26 (patch) | |
| tree | 5e271422c3ddb54a4591c1eac6067c6c5a19f780 /clang/unittests/Format/FormatTest.cpp | |
| parent | 8b51bab4958c0dddbfbbff92bc2ed0522dfec87b (diff) | |
| download | bcm5719-llvm-aa1c920db85e7ac07d09b80eedc66bae7e358f26.tar.gz bcm5719-llvm-aa1c920db85e7ac07d09b80eedc66bae7e358f26.zip | |
Indentation fixes for clang-format.
- Fix behavior of memoization together with optimization
- Correctly attribute the PenaltyIndentLevel (breaking directly after "(" did
not count towards the inner level)
- Recognize more tokens as assignments
Review: http://llvm-reviews.chandlerc.com/D172
llvm-svn: 169384
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index be4363353e6..c9860d595ce 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -110,6 +110,7 @@ TEST_F(FormatTest, FormatIfWithoutCompountStatement) { verifyFormat("if (true)\n f();\ng();"); verifyFormat("if (a)\n if (b)\n if (c)\n g();\nh();"); verifyFormat("if (a)\n if (b) {\n f();\n }\ng();"); + EXPECT_EQ("if (a)\n // comment\n f();", format("if(a)\n// comment\nf();")); } TEST_F(FormatTest, ParseIfThenElse) { @@ -277,6 +278,17 @@ TEST_F(FormatTest, BreaksDesireably) { " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)),\n" " aaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)));"); + + verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ||\n" + " (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);"); + + // This test case breaks on an incorrect memoization, i.e. an optimization not + // taking into account the StopAt value. + verifyFormat( + "return aaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaa ||\n" + " aaaaaaaaaaa(aaaaaaaaa) || aaaaaaaaaaaaaaaaaaaaaaa ||\n" + " aaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaa ||\n" + " (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);"); } TEST_F(FormatTest, AlignsStringLiterals) { @@ -350,6 +362,10 @@ TEST_F(FormatTest, UnderstandsUsesOfStar) { verifyFormat("int a = b * 10;"); verifyFormat("int a = 10 * b;"); verifyFormat("int a = b * c;"); + verifyFormat("int a += b * c;"); + verifyFormat("int a -= b * c;"); + verifyFormat("int a *= b * c;"); + verifyFormat("int a /= b * c;"); verifyFormat("int a = *b;"); verifyFormat("int a = *b * c;"); verifyFormat("int a = b * *c;"); |

