summaryrefslogtreecommitdiff
path: root/unittests/Format
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-06-03 12:02:45 +0000
committerDaniel Jasper <djasper@google.com>2014-06-03 12:02:45 +0000
commite167891bd8ce378c40f9e78051b5ffeb9dec6284 (patch)
treefa25524650e68cb8b2cfbe78b83d47af97831470 /unittests/Format
parenta51e4bfa5b6b5535901075e3dbcdb944c543f5ca (diff)
downloadclang-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.cpp33
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]; }");
}