summaryrefslogtreecommitdiffstats
path: root/unittests/Format/FormatTestJS.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'unittests/Format/FormatTestJS.cpp')
-rw-r--r--unittests/Format/FormatTestJS.cpp37
1 files changed, 32 insertions, 5 deletions
diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp
index 67b99ba146..b332f1bd97 100644
--- a/unittests/Format/FormatTestJS.cpp
+++ b/unittests/Format/FormatTestJS.cpp
@@ -1,9 +1,8 @@
//===- unittest/Format/FormatTestJS.cpp - Formatting unit tests for JS ----===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -1963,6 +1962,12 @@ TEST_F(FormatTestJS, NestedTemplateStrings) {
TEST_F(FormatTestJS, TaggedTemplateStrings) {
verifyFormat("var x = html`<ul>`;");
verifyFormat("yield `hello`;");
+ verifyFormat("var f = {\n"
+ " param: longTagName`This is a ${\n"
+ " 'really'} long line`\n"
+ "};",
+ "var f = {param: longTagName`This is a ${'really'} long line`};",
+ getGoogleJSStyleWithColumns(40));
}
TEST_F(FormatTestJS, CastSyntax) {
@@ -2329,5 +2334,27 @@ TEST_F(FormatTestJS, ConditionalTypes) {
" never) extends((k: infer I) => void) ? I : never;");
}
-} // end namespace tooling
+TEST_F(FormatTestJS, SupportPrivateFieldsAndMethods) {
+ verifyFormat("class Example {\n"
+ " pub = 1;\n"
+ " #priv = 2;\n"
+ " static pub2 = 'foo';\n"
+ " static #priv2 = 'bar';\n"
+ " method() {\n"
+ " this.#priv = 5;\n"
+ " }\n"
+ " static staticMethod() {\n"
+ " switch (this.#priv) {\n"
+ " case '1':\n"
+ " #priv = 3;\n"
+ " break;\n"
+ " }\n"
+ " }\n"
+ " #privateMethod() {\n"
+ " this.#privateMethod(); // infinite loop\n"
+ " }\n"
+ " static #staticPrivateMethod() {}\n");
+}
+
+} // namespace format
} // end namespace clang