summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTestJS.cpp
diff options
context:
space:
mode:
authorMartin Probst <martin@probst.io>2017-04-27 13:07:24 +0000
committerMartin Probst <martin@probst.io>2017-04-27 13:07:24 +0000
commit973ff79e2979abe41b1ff9d18599f7c87b6ef432 (patch)
treea886864142bd730b07884412ac068a51c0541848 /clang/unittests/Format/FormatTestJS.cpp
parent63a978ff090444923be34e4022b2d15937d5f139 (diff)
downloadbcm5719-llvm-973ff79e2979abe41b1ff9d18599f7c87b6ef432.tar.gz
bcm5719-llvm-973ff79e2979abe41b1ff9d18599f7c87b6ef432.zip
clang-format: [JS] parse async function declarations.
Summary: Previously, clang-format would accidentally parse an async function declaration as a function expression, and thus not insert an unwrapped line for async functions, causing subsequent functions to run into the function: async function f() { x(); } function g() { ... With this change, async functions get parsed as top level function declarations and get their own unwrapped line context. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D32590 llvm-svn: 301538
Diffstat (limited to 'clang/unittests/Format/FormatTestJS.cpp')
-rw-r--r--clang/unittests/Format/FormatTestJS.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index 7886c4fe27a..eda9e0a31da 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -485,6 +485,20 @@ TEST_F(FormatTestJS, AsyncFunctions) {
" let x = 1;\n"
" return fetch(x);\n"
"}");
+ verifyFormat("async function f() {\n"
+ " return 1;\n"
+ "}\n"
+ "\n"
+ "function a() {\n"
+ " return 1;\n"
+ "}\n",
+ " async function f() {\n"
+ " return 1;\n"
+ "}\n"
+ "\n"
+ " function a() {\n"
+ " return 1;\n"
+ "} \n");
verifyFormat("async function* f() {\n"
" yield fetch(x);\n"
"}");
@@ -492,6 +506,9 @@ TEST_F(FormatTestJS, AsyncFunctions) {
" return fetch(x);\n"
"}");
verifyFormat("let x = async () => f();");
+ verifyFormat("let x = async function() {\n"
+ " f();\n"
+ "};");
verifyFormat("let x = async();");
verifyFormat("class X {\n"
" async asyncMethod() {\n"
OpenPOWER on IntegriCloud