clang-format: [JS] support closures in container literals.
Before:
return {body: {setAttribute: function(key, val) {this[key] = val;
}
, getAttribute : function(key) { return this[key]; }
, style : {
direction:
''
}
}
}
;
After:
return {
body: {
setAttribute: function(key, val) { this[key] = val; },
getAttribute: function(key) { return this[key]; },
style: {direction: ''}
}
};
llvm-svn: 208292
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index 606303a..2dfd10f 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -101,6 +101,13 @@
TEST_F(FormatTestJS, Closures) {
verifyFormat("doFoo(function() { return 1; });");
verifyFormat("var func = function() { return 1; };");
+ verifyFormat("return {\n"
+ " body: {\n"
+ " setAttribute: function(key, val) { this[key] = val; },\n"
+ " getAttribute: function(key) { return this[key]; },\n"
+ " style: {direction: ''}\n"
+ " }\n"
+ "};");
}
TEST_F(FormatTestJS, ReturnStatements) {