Skip to content

Commit 736a380

Browse files
committed
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
1 parent 23c1138 commit 736a380

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

clang/unittests/Format/FormatTestJS.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,22 @@ TEST_F(FormatTestJS, AsyncFunctions) {
737737
" function a() {\n"
738738
" return 1;\n"
739739
"} \n");
740+
// clang-format must not insert breaks between async and function, otherwise
741+
// automatic semicolon insertion may trigger (in particular in a class body).
742+
verifyFormat("async function\n"
743+
"hello(\n"
744+
" myparamnameiswaytooloooong) {\n"
745+
"}",
746+
"async function hello(myparamnameiswaytooloooong) {}",
747+
getGoogleJSStyleWithColumns(10));
748+
verifyFormat("class C {\n"
749+
" async hello(\n"
750+
" myparamnameiswaytooloooong) {\n"
751+
" }\n"
752+
"}",
753+
"class C {\n"
754+
" async hello(myparamnameiswaytooloooong) {} }",
755+
getGoogleJSStyleWithColumns(10));
740756
verifyFormat("async function* f() {\n"
741757
" yield fetch(x);\n"
742758
"}");

0 commit comments

Comments
 (0)