From f8e1f5c7d38d0298d7b078838b22ef24ec98aa45 Mon Sep 17 00:00:00 2001 From: Martin Probst Date: Fri, 26 Jan 2018 15:07:49 +0000 Subject: clang-format: [JS] Prevent ASI before [ and (. Summary: JavaScript automatic semicolon insertion can trigger before [ and (, so avoid breaking before them if the previous token is likely to terminate an expression. Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D42570 llvm-svn: 323532 --- clang/unittests/Format/FormatTestJS.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'clang/unittests/Format') diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index 2a929563f75..47886521008 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -1157,6 +1157,9 @@ TEST_F(FormatTestJS, WrapRespectsAutomaticSemicolonInsertion) { "foo() {}", getGoogleJSStyleWithColumns(10)); verifyFormat("await theReckoning;", getGoogleJSStyleWithColumns(10)); + verifyFormat("some['a']['b']", getGoogleJSStyleWithColumns(10)); + verifyFormat("x = (a['a']\n" + " ['b']);", getGoogleJSStyleWithColumns(10)); } TEST_F(FormatTestJS, AutomaticSemicolonInsertionHeuristic) { -- cgit v1.2.3