diff options
author | Daniel Jasper <djasper@google.com> | 2014-12-04 16:07:17 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2014-12-04 16:07:17 +0000 |
commit | a4e55f4d1ec87056703c752644e12640e97fb5a1 (patch) | |
tree | 2b662c38b633c30ea8a172f10aaf1aa272a9e7e6 /clang/unittests/Format/FormatTestJS.cpp | |
parent | d33304b3adfea0eb407984cc93a508d252a656e6 (diff) | |
download | bcm5719-llvm-a4e55f4d1ec87056703c752644e12640e97fb5a1.tar.gz bcm5719-llvm-a4e55f4d1ec87056703c752644e12640e97fb5a1.zip |
clang-format: [JS] Don't put top-level dict literals on a single line.
These are often used for enums which apparently are easier to read if
formatted with one element per line.
llvm-svn: 223367
Diffstat (limited to 'clang/unittests/Format/FormatTestJS.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTestJS.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index 0d29c178f8b..23654a88483 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -94,7 +94,10 @@ TEST_F(FormatTestJS, LiteralOperatorsCanBeKeywords) { TEST_F(FormatTestJS, ES6DestructuringAssignment) { verifyFormat("var [a, b, c] = [1, 2, 3];"); - verifyFormat("var {a, b} = {a: 1, b: 2};"); + verifyFormat("var {a, b} = {\n" + " a: 1,\n" + " b: 2\n" + "};"); } TEST_F(FormatTestJS, ContainerLiterals) { @@ -140,16 +143,16 @@ TEST_F(FormatTestJS, ContainerLiterals) { TEST_F(FormatTestJS, SpacesInContainerLiterals) { verifyFormat("var arr = [1, 2, 3];"); - verifyFormat("var obj = {a: 1, b: 2, c: 3};"); + verifyFormat("f({a: 1, b: 2, c: 3});"); verifyFormat("var object_literal_with_long_name = {\n" " a: 'aaaaaaaaaaaaaaaaaa',\n" " b: 'bbbbbbbbbbbbbbbbbb'\n" "};"); - verifyFormat("var obj = {a: 1, b: 2, c: 3};", + verifyFormat("f({a: 1, b: 2, c: 3});", getChromiumStyle(FormatStyle::LK_JavaScript)); - verifyFormat("someVariable = {'a': [{}]};"); + verifyFormat("f({'a': [{}]});"); } TEST_F(FormatTestJS, SingleQuoteStrings) { @@ -238,12 +241,12 @@ TEST_F(FormatTestJS, FunctionLiterals) { " };\n" "}"); - verifyFormat("var x = {a: function() { return 1; }};", - getGoogleJSStyleWithColumns(38)); - verifyFormat("var x = {\n" + verifyFormat("f({a: function() { return 1; }});", + getGoogleJSStyleWithColumns(33)); + verifyFormat("f({\n" " a: function() { return 1; }\n" - "};", - getGoogleJSStyleWithColumns(37)); + "});", + getGoogleJSStyleWithColumns(32)); verifyFormat("return {\n" " a: function SomeFunction() {\n" |