From: Daniel Jasper Date: Fri, 12 Jun 2015 04:58:27 +0000 (+0000) Subject: clang-format: [JS] Add tests to ensure clang-format doesn't break code X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=977b0881116940c3144b978f872f679845d5d44e;p=clang clang-format: [JS] Add tests to ensure clang-format doesn't break code by triggering automatic semicolon insertion changes. NFC intended. Patch by Martin Probst. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239594 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp index 0f9f38240a..888d73d48e 100644 --- a/unittests/Format/FormatTestJS.cpp +++ b/unittests/Format/FormatTestJS.cpp @@ -521,6 +521,18 @@ TEST_F(FormatTestJS, ReturnStatements) { "}"); } +TEST_F(FormatTestJS, AutomaticSemicolonInsertion) { + // The following statements must not wrap, as otherwise the program meaning + // would change due to automatic semicolon insertion. + // See http://www.ecma-international.org/ecma-262/5.1/#sec-7.9.1. + verifyFormat("return aaaaa;", getGoogleJSStyleWithColumns(10)); + verifyFormat("continue aaaaa;", getGoogleJSStyleWithColumns(10)); + verifyFormat("break aaaaa;", getGoogleJSStyleWithColumns(10)); + verifyFormat("throw aaaaa;", getGoogleJSStyleWithColumns(10)); + verifyFormat("aaaaaaaaa++;", getGoogleJSStyleWithColumns(10)); + verifyFormat("aaaaaaaaa--;", getGoogleJSStyleWithColumns(10)); +} + TEST_F(FormatTestJS, ClosureStyleCasts) { verifyFormat("var x = /** @type {foo} */ (bar);"); }