r239594 - clang-format: [JS] Add tests to ensure clang-format doesn't break code
Daniel Jasper
djasper at google.com
Thu Jun 11 21:58:27 PDT 2015
Author: djasper
Date: Thu Jun 11 23:58:27 2015
New Revision: 239594
URL: http://llvm.org/viewvc/llvm-project?rev=239594&view=rev
Log:
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.
Modified:
cfe/trunk/unittests/Format/FormatTestJS.cpp
Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=239594&r1=239593&r2=239594&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Thu Jun 11 23:58:27 2015
@@ -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);");
}
More information about the cfe-commits
mailing list