diff options
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 |