clang-format: [JS] Making arrow function wrapping more consistent.
Before:
someFunction(() =>
{
doSomething(); // break
})
.doSomethingElse( // break
);
After:
someFunction(() => {
doSomething(); // break
})
.doSomethingElse( // break
);
This is still bad, but at least it is consistent with what we do for other
function literals. Added corresponding tests.
llvm-svn: 238736
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index 29b8aa1..20c10b6 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -337,6 +337,14 @@
" doSomething();\n"
" doSomething();\n"
" }, this));");
+
+ // FIXME: This is bad, we should be wrapping before "function() {".
+ verifyFormat("someFunction(function() {\n"
+ " doSomething(); // break\n"
+ "})\n"
+ " .doSomethingElse(\n"
+ " // break\n"
+ " );");
}
TEST_F(FormatTestJS, InliningFunctionLiterals) {
@@ -455,7 +463,14 @@
" return a;\n"
"};");
verifyFormat("var x = (a) => a;");
- verifyFormat("var x = (a) => a;");
+
+ // FIXME: This is bad, we should be wrapping before "() => {".
+ verifyFormat("someFunction(() => {\n"
+ " doSomething(); // break\n"
+ "})\n"
+ " .doSomethingElse(\n"
+ " // break\n"
+ " );");
}
TEST_F(FormatTestJS, ReturnStatements) {