summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTestJS.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-06-01 09:56:32 +0000
committerDaniel Jasper <djasper@google.com>2015-06-01 09:56:32 +0000
commit1699eca119e3488a21dfe50cbbfe8f1508b23eb3 (patch)
treec8d947ef361f67c2d16a11b30ab48de60bd5b83e /clang/unittests/Format/FormatTestJS.cpp
parent0c41088ebfd9b9bc800d7f6d440733f22bb2d364 (diff)
downloadbcm5719-llvm-1699eca119e3488a21dfe50cbbfe8f1508b23eb3.tar.gz
bcm5719-llvm-1699eca119e3488a21dfe50cbbfe8f1508b23eb3.zip
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
Diffstat (limited to 'clang/unittests/Format/FormatTestJS.cpp')
-rw-r--r--clang/unittests/Format/FormatTestJS.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index 29b8aa1ff13..20c10b634bf 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -337,6 +337,14 @@ TEST_F(FormatTestJS, FunctionLiterals) {
" 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 @@ TEST_F(FormatTestJS, ArrowFunctions) {
" 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) {
OpenPOWER on IntegriCloud