diff options
author | Daniel Jasper <djasper@google.com> | 2015-06-12 04:58:27 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2015-06-12 04:58:27 +0000 |
commit | 4c0bf7034c7383acb10e0d162feeb2ae58d14d5b (patch) | |
tree | 8a4e01609f5a432161ddbc7bd60113d4c9b8c927 /clang/unittests/Format/FormatTestJS.cpp | |
parent | 259188b1b58e9441d0aff11537a589b61ce611ed (diff) | |
download | bcm5719-llvm-4c0bf7034c7383acb10e0d162feeb2ae58d14d5b.tar.gz bcm5719-llvm-4c0bf7034c7383acb10e0d162feeb2ae58d14d5b.zip |
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.
llvm-svn: 239594
Diffstat (limited to 'clang/unittests/Format/FormatTestJS.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTestJS.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index 0f9f38240a3..888d73d48ee 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/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);"); } |