summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r--clang/unittests/Format/FormatTest.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 97cc2614e89..65124a80575 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -7816,6 +7816,49 @@ TEST_F(FormatTest, FormatsBlocks) {
verifyFormat("[operation setCompletionBlock:^{ [self onOperationDone]; }];");
verifyFormat("int i = {[operation setCompletionBlock : ^{ [self "
"onOperationDone]; }] };");
+ verifyFormat("[operation setCompletionBlock:^(int *i) { f(); }];");
+
+ verifyFormat("[operation setCompletionBlock:^{\n"
+ " [self.delegate newDataAvailable];\n"
+ "}];",
+ getLLVMStyleWithColumns(60));
+ verifyFormat("dispatch_async(_fileIOQueue, ^{\n"
+ " NSString *path = [self sessionFilePath];\n"
+ " if (path) {\n"
+ " // ...\n"
+ " }\n"
+ "});");
+ verifyFormat("[[SessionService sharedService]\n"
+ " loadWindowWithCompletionBlock:^(SessionWindow *window) {\n"
+ " if (window) {\n"
+ " [self windowDidLoad:window];\n"
+ " } else {\n"
+ " [self errorLoadingWindow];\n"
+ " }\n"
+ " }];");
+ verifyFormat("void (^largeBlock)(void) = ^{\n"
+ " // ...\n"
+ "};\n",
+ getLLVMStyleWithColumns(40));
+ verifyFormat("[[SessionService sharedService]\n"
+ " loadWindowWithCompletionBlock: //\n"
+ " ^(SessionWindow *window) {\n"
+ " if (window) {\n"
+ " [self windowDidLoad:window];\n"
+ " } else {\n"
+ " [self errorLoadingWindow];\n"
+ " }\n"
+ " }];",
+ getLLVMStyleWithColumns(60));
+ verifyFormat("[myObject doSomethingWith:arg1\n"
+ " firstBlock:^(Foo *a) {\n"
+ " // ...\n"
+ " int i;\n"
+ " }\n"
+ " secondBlock:^(Bar *b) {\n"
+ " // ...\n"
+ " int i;\n"
+ " }];");
}
TEST_F(FormatTest, SupportsCRLF) {
OpenPOWER on IntegriCloud