diff options
author | Daniel Jasper <djasper@google.com> | 2013-04-02 14:33:13 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-04-02 14:33:13 +0000 |
commit | 3791130df5ad83e4a9872f90cc9675e90b772f88 (patch) | |
tree | 208d7eb0ad590bf83daeceb9f1f04ef68cd09270 /unittests/Format | |
parent | ddc15c40d22718d7b7060634b782d1a3ce9184a8 (diff) |
Fix some inconsistent use of indentation.
Basically we have always special-cased the top-level statement of an
unwrapped line (the one with ParenLevel == 0) and that lead to several
inconsistencies. All added tests were formatted in a strange way, for
example:
Before:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa();
if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()) {
}
After:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa();
if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()) {
}
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178542 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Format')
-rw-r--r-- | unittests/Format/FormatTest.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index df93fbd05a..3f26b0a482 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -1670,7 +1670,7 @@ TEST_F(FormatTest, FormatsBuilderPattern) { " .Default(ORDER_TEXT);\n"); verifyFormat("return aaaaaaaaaaaaaaaaa->aaaaa().aaaaaaaaaaaaa().aaaaaa() <\n" - " aaaaaaaaaaaaaaaaaaa->aaaaa().aaaaaaaaaaaaa().aaaaaa();"); + " aaaaaaaaaaaaaaa->aaaaa().aaaaaaaaaaaaa().aaaaaa();"); verifyFormat( "aaaaaaa->aaaaaaa\n" " ->aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" @@ -1765,6 +1765,12 @@ TEST_F(FormatTest, AlignsAfterReturn) { verifyFormat( "return (aaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaa +\n" " aaaaaaaaaaaaaaaaaaaaaaaaa);"); + verifyFormat( + "return aaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa >=\n" + " aaaaaaaaaaaaaaaaaaaaaa();"); + verifyFormat( + "return (aaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa >=\n" + " aaaaaaaaaaaaaaaaaaaaaa());"); } TEST_F(FormatTest, BreaksConditionalExpressions) { @@ -1799,6 +1805,10 @@ TEST_F(FormatTest, BreaksConditionalExpressions) { verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" " ? aaaaaaaaaaaaaaaaaaaaaaaaaaa\n" " : aaaaaaaaaaaaaaaaaaaaaaaaaaa;"); + verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaa =\n" + " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" + " ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" + " : aaaaaaaaaaaaaaaa;"); verifyFormat( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" " ? aaaaaaaaaaaaaaa\n" @@ -1837,7 +1847,7 @@ TEST_F(FormatTest, DeclarationsOfMultipleVariables) { verifyFormat("bool aaaaaaaaaaaaaaaaaaaaaaaaa =\n" " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaa),\n" " bbbbbbbbbbbbbbbbbbbbbbbbb =\n" - " bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(bbbbbbbbbbbbbbbb);"); + " bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(bbbbbbbbbbbbbbbb);"); verifyFormat( "bool aaaaaaaaaaaaaaaaaaaaa =\n" " bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb && cccccccccccccccccccccccccccc,\n" @@ -1920,6 +1930,10 @@ TEST_F(FormatTest, AlignsPipes) { " << \"eeeeeeeeeeeeeeeee = \" << eeeeeeeeeeeeeeeee;"); verifyFormat("llvm::outs() << aaaaaaaaaaaaaaaaaaaaaaaa << \"=\"\n" " << bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;"); + + verifyFormat( + "llvm::errs() << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" + " .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa();"); } TEST_F(FormatTest, UnderstandsEquals) { @@ -1973,6 +1987,11 @@ TEST_F(FormatTest, WrapsAtFunctionCallsIfNecessary) { " .aaaaaaaaaaaaaaa(\n" " aa(aaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" " aaaaaaaaaaaaaaaaaaaaaaaaaaa));"); + verifyFormat("if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" + " .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" + " .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" + " .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()) {\n" + "}"); // Here, it is not necessary to wrap at "." or "->". verifyFormat("if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaa) ||\n" @@ -2068,6 +2087,10 @@ TEST_F(FormatTest, WrapsAtNestedNameSpecifiers) { " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" " aaaaaaaaaaaaaaaaaaaaa);", getLLVMStyleWithColumns(74)); + + verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa::\n" + " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" + " .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa();"); } TEST_F(FormatTest, UnderstandsTemplateParameters) { |