diff options
| author | Daniel Jasper <djasper@google.com> | 2013-12-23 07:29:06 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2013-12-23 07:29:06 +0000 |
| commit | b88b25feec83a945083c8a9d7eb9f4207ef08195 (patch) | |
| tree | 42ffa2590fa185ea9d2385d0b6fae3dc3e962995 /clang/unittests/Format/FormatTest.cpp | |
| parent | a650116adb60da5479cfad866bd77163d27c1013 (diff) | |
| download | bcm5719-llvm-b88b25feec83a945083c8a9d7eb9f4207ef08195.tar.gz bcm5719-llvm-b88b25feec83a945083c8a9d7eb9f4207ef08195.zip | |
clang-format: Fix various problems in formatting ObjC blocks.
Among other things, this fixes llvm.org/PR15269.
llvm-svn: 197900
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 43 |
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) { |

