diff options
author | Daniel Jasper <djasper@google.com> | 2014-10-22 09:12:44 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2014-10-22 09:12:44 +0000 |
commit | 76284683f12a7b8c98711963f59662d679f70712 (patch) | |
tree | c623942055dcdb53646d07b2f2669573d563f0b1 /clang/unittests/Format/FormatTest.cpp | |
parent | b52c69e56777eabd4570464b96a7dd1129c2bb91 (diff) | |
download | bcm5719-llvm-76284683f12a7b8c98711963f59662d679f70712.tar.gz bcm5719-llvm-76284683f12a7b8c98711963f59662d679f70712.zip |
clang-format: Use AllowShortBlocksOnASingleLine for ObjC blocks, too.
llvm-svn: 220375
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index b19e3cb44be..7c2e6c396ec 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -9154,24 +9154,35 @@ TEST_F(FormatTest, FormatsLambdas) { } TEST_F(FormatTest, FormatsBlocks) { - verifyFormat("int (^Block)(int, int);"); - verifyFormat("int (^Block1)(int, int) = ^(int i, int j)"); - verifyFormat("void (^block)(int) = ^(id test) { int i; };"); - verifyFormat("void (^block)(int) = ^(int test) { int i; };"); - verifyFormat("void (^block)(int) = ^id(int test) { int i; };"); - verifyFormat("void (^block)(int) = ^int(int test) { int i; };"); - - verifyFormat("foo(^{ bar(); });"); - verifyFormat("foo(a, ^{ bar(); });"); - verifyFormat("{ void (^block)(Object *x); }"); - - verifyFormat("[operation setCompletionBlock:^{ [self onOperationDone]; }];"); - verifyFormat("int i = {[operation setCompletionBlock:^{ [self " - "onOperationDone]; }]};"); - verifyFormat("[operation setCompletionBlock:^(int *i) { f(); }];"); - verifyFormat("int a = [operation block:^int(int *i) { return 1; }];"); + FormatStyle ShortBlocks = getLLVMStyle(); + ShortBlocks.AllowShortBlocksOnASingleLine = true; + verifyFormat("int (^Block)(int, int);", ShortBlocks); + verifyFormat("int (^Block1)(int, int) = ^(int i, int j)", ShortBlocks); + verifyFormat("void (^block)(int) = ^(id test) { int i; };", ShortBlocks); + verifyFormat("void (^block)(int) = ^(int test) { int i; };", ShortBlocks); + verifyFormat("void (^block)(int) = ^id(int test) { int i; };", ShortBlocks); + verifyFormat("void (^block)(int) = ^int(int test) { int i; };", ShortBlocks); + + verifyFormat("foo(^{ bar(); });", ShortBlocks); + verifyFormat("foo(a, ^{ bar(); });", ShortBlocks); + verifyFormat("{ void (^block)(Object *x); }", ShortBlocks); + + verifyFormat("[operation setCompletionBlock:^{\n" + " [self onOperationDone];\n" + "}];"); + verifyFormat("int i = {[operation setCompletionBlock:^{\n" + " [self onOperationDone];\n" + "}]};"); + verifyFormat("[operation setCompletionBlock:^(int *i) {\n" + " f();\n" + "}];"); + verifyFormat("int a = [operation block:^int(int *i) {\n" + " return 1;\n" + "}];"); verifyFormat("[myObject doSomethingWith:arg1\n" - " aaa:^int(int *a) { return 1; }\n" + " aaa:^int(int *a) {\n" + " return 1;\n" + " }\n" " bbb:f(a * bbbbbbbb)];"); verifyFormat("[operation setCompletionBlock:^{\n" |