diff options
author | Daniel Jasper <djasper@google.com> | 2014-06-03 12:02:45 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2014-06-03 12:02:45 +0000 |
commit | e167891bd8ce378c40f9e78051b5ffeb9dec6284 (patch) | |
tree | fa25524650e68cb8b2cfbe78b83d47af97831470 /unittests/Format | |
parent | a51e4bfa5b6b5535901075e3dbcdb944c543f5ca (diff) | |
download | clang-e167891bd8ce378c40f9e78051b5ffeb9dec6284.tar.gz clang-e167891bd8ce378c40f9e78051b5ffeb9dec6284.tar.bz2 clang-e167891bd8ce378c40f9e78051b5ffeb9dec6284.tar.xz |
clang-format: Refactor indentation behavior for multiple nested blocks.
This fixes a few oddities when formatting multiple nested JavaScript
blocks, e.g.:
Before:
promise.then(
function success() {
doFoo();
doBar();
},
[], function error() {
doFoo();
doBaz();
});
promise.then([],
function success() {
doFoo();
doBar();
},
function error() {
doFoo();
doBaz();
});
After:
promise.then(
function success() {
doFoo();
doBar();
},
[],
function error() {
doFoo();
doBaz();
});
promise.then([],
function success() {
doFoo();
doBar();
},
function error() {
doFoo();
doBaz();
});
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210097 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Format')
-rw-r--r-- | unittests/Format/FormatTestJS.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp index ecf4e69999..ddd594bb6e 100644 --- a/unittests/Format/FormatTestJS.cpp +++ b/unittests/Format/FormatTestJS.cpp @@ -146,6 +146,39 @@ TEST_F(FormatTestJS, Closures) { getGoogleJSStyleWithColumns(37)); } +TEST_F(FormatTestJS, MultipleFunctionLiterals) { + verifyFormat("promise.then(\n" + " function success() {\n" + " doFoo();\n" + " doBar();\n" + " },\n" + " function error() {\n" + " doFoo();\n" + " doBaz();\n" + " },\n" + " []);\n"); + verifyFormat("promise.then(\n" + " function success() {\n" + " doFoo();\n" + " doBar();\n" + " },\n" + " [],\n" + " function error() {\n" + " doFoo();\n" + " doBaz();\n" + " });\n"); + // FIXME: Here, we should probably break right after the "(" for consistency. + verifyFormat("promise.then([],\n" + " function success() {\n" + " doFoo();\n" + " doBar();\n" + " },\n" + " function error() {\n" + " doFoo();\n" + " doBaz();\n" + " });\n"); +} + TEST_F(FormatTestJS, ReturnStatements) { verifyFormat("function() { return [hello, world]; }"); } |