[clang] 736a380 - clang-format: [JS] tests for async wrapping.

Martin Probst via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 16 02:23:22 PST 2020


Author: Martin Probst
Date: 2020-01-16T11:23:11+01:00
New Revision: 736a3802124b57490fa1e67538415a2a77fa731c

URL: https://github.com/llvm/llvm-project/commit/736a3802124b57490fa1e67538415a2a77fa731c
DIFF: https://github.com/llvm/llvm-project/commit/736a3802124b57490fa1e67538415a2a77fa731c.diff

LOG: clang-format: [JS] tests for async wrapping.

Summary:
Adds tests to ensure that `async method() ...` does not wrap between async and
the method name, which would cause automatic semicolon insertion.

Reviewers: krasimir

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D70377

Added: 
    

Modified: 
    clang/unittests/Format/FormatTestJS.cpp

Removed: 
    


################################################################################
diff  --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index 619a19f1a22d..f5be0d7a4ab1 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -737,6 +737,22 @@ TEST_F(FormatTestJS, AsyncFunctions) {
                "   function a() {\n"
                "  return   1;\n"
                "}  \n");
+  // clang-format must not insert breaks between async and function, otherwise
+  // automatic semicolon insertion may trigger (in particular in a class body).
+  verifyFormat("async function\n"
+               "hello(\n"
+               "    myparamnameiswaytooloooong) {\n"
+               "}",
+               "async function hello(myparamnameiswaytooloooong) {}",
+               getGoogleJSStyleWithColumns(10));
+  verifyFormat("class C {\n"
+               "  async hello(\n"
+               "      myparamnameiswaytooloooong) {\n"
+               "  }\n"
+               "}",
+               "class C {\n"
+               "  async hello(myparamnameiswaytooloooong) {} }",
+               getGoogleJSStyleWithColumns(10));
   verifyFormat("async function* f() {\n"
                "  yield fetch(x);\n"
                "}");


        


More information about the cfe-commits mailing list