summaryrefslogtreecommitdiffstats
path: root/unittests
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-11-14 13:03:40 +0000
committerDaniel Jasper <djasper@google.com>2014-11-14 13:03:40 +0000
commit0364e8eb312bb945fa1f4f59fb104733f9383be8 (patch)
tree05c60ad10f10c23f573b12724df86be5c77a9f75 /unittests
parent712b8b0eeac5f2fc449f1df4e9c51b18e0e706be (diff)
clang-format: Support assignments as conditional operands.
Before: return a != b // comment ? a : a = a != b // comment ? a = b : a; After: return a != b // comment ? a : a = a != b // comment ? a = b : a; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221987 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/Format/FormatTest.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index d2e577aacb..0510871a05 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -4132,6 +4132,26 @@ TEST_F(FormatTest, BreaksConditionalExpressions) {
" ccccccccccccccccccccccccccccccccccccccc\n"
" ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
" : bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb);");
+
+ // Assignments in conditional expressions. Apparently not uncommon :-(.
+ verifyFormat("return a != b\n"
+ " // comment\n"
+ " ? a = b\n"
+ " : a = b;");
+ verifyFormat("return a != b\n"
+ " // comment\n"
+ " ? a = a != b\n"
+ " // comment\n"
+ " ? a = b\n"
+ " : a\n"
+ " : a;\n");
+ verifyFormat("return a != b\n"
+ " // comment\n"
+ " ? a\n"
+ " : a = a != b\n"
+ " // comment\n"
+ " ? a = b\n"
+ " : a;");
}
TEST_F(FormatTest, BreaksConditionalExpressionsAfterOperator) {