diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-06-10 13:44:22 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-06-10 13:44:22 +0000 |
commit | 1b08b196ac845675036ac78f3ac927d0a37f707c (patch) | |
tree | 1fbd923674e903831dc097fdb4fdfd64dd6e47b1 /unittests/Format/FormatTestJS.cpp | |
parent | 551c698530debaae81139c7c76a29fb762793362 (diff) |
Diffstat (limited to 'unittests/Format/FormatTestJS.cpp')
-rw-r--r-- | unittests/Format/FormatTestJS.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp index 92a113111b6a..e84f470687ec 100644 --- a/unittests/Format/FormatTestJS.cpp +++ b/unittests/Format/FormatTestJS.cpp @@ -1226,6 +1226,12 @@ TEST_F(FormatTestJS, UnionIntersectionTypes) { verifyFormat("let x: Bar|Baz;"); verifyFormat("let x: Bar<X>|Baz;"); verifyFormat("let x: (Foo|Bar)[];"); + verifyFormat("type X = {\n" + " a: Foo|Bar;\n" + "};"); + verifyFormat("export type X = {\n" + " a: Foo|Bar;\n" + "};"); } TEST_F(FormatTestJS, ClassDeclarations) { @@ -1869,5 +1875,44 @@ TEST_F(FormatTestJS, Exponentiation) { verifyFormat("squared **= 2;"); } +TEST_F(FormatTestJS, NestedLiterals) { + FormatStyle FourSpaces = getGoogleJSStyleWithColumns(15); + FourSpaces.IndentWidth = 4; + verifyFormat("var l = [\n" + " [\n" + " 1,\n" + " ],\n" + "];", FourSpaces); + verifyFormat("var l = [\n" + " {\n" + " 1: 1,\n" + " },\n" + "];", FourSpaces); + verifyFormat("someFunction(\n" + " p1,\n" + " [\n" + " 1,\n" + " ],\n" + ");", FourSpaces); + verifyFormat("someFunction(\n" + " p1,\n" + " {\n" + " 1: 1,\n" + " },\n" + ");", FourSpaces); + verifyFormat("var o = {\n" + " 1: 1,\n" + " 2: {\n" + " 3: 3,\n" + " },\n" + "};", FourSpaces); + verifyFormat("var o = {\n" + " 1: 1,\n" + " 2: [\n" + " 3,\n" + " ],\n" + "};", FourSpaces); +} + } // end namespace tooling } // end namespace clang |