summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format
diff options
context:
space:
mode:
Diffstat (limited to 'clang/unittests/Format')
-rw-r--r--clang/unittests/Format/FormatTestComments.cpp6
-rw-r--r--clang/unittests/Format/FormatTestJS.cpp45
2 files changed, 31 insertions, 20 deletions
diff --git a/clang/unittests/Format/FormatTestComments.cpp b/clang/unittests/Format/FormatTestComments.cpp
index 2b07dedf670..9f43677b70d 100644
--- a/clang/unittests/Format/FormatTestComments.cpp
+++ b/clang/unittests/Format/FormatTestComments.cpp
@@ -1254,6 +1254,12 @@ TEST_F(FormatTestComments, SplitsLongLinesInComments) {
" */",
getLLVMStyleWithColumns(20)));
+ // This reproduces a crashing bug where both adaptStartOfLine and
+ // getCommentSplit were trying to wrap after the "/**".
+ EXPECT_EQ("/** multilineblockcommentwithnowrapopportunity */",
+ format("/** multilineblockcommentwithnowrapopportunity */",
+ getLLVMStyleWithColumns(20)));
+
EXPECT_EQ("/*\n"
"\n"
"\n"
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index e7808c6596d..fe148393b98 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -191,31 +191,32 @@ TEST_F(FormatTestJS, JSDocComments) {
// Break a single line long jsdoc comment pragma.
EXPECT_EQ("/**\n"
- " * @returns\n"
- " * {string}\n"
- " * jsdoc line 12\n"
+ " * @returns {string} jsdoc line 12\n"
" */",
format("/** @returns {string} jsdoc line 12 */",
getGoogleJSStyleWithColumns(20)));
-
EXPECT_EQ("/**\n"
- " * @returns\n"
- " * {string}\n"
+ " * @returns {string}\n"
" * jsdoc line 12\n"
" */",
+ format("/** @returns {string} jsdoc line 12 */",
+ getGoogleJSStyleWithColumns(25)));
+
+ EXPECT_EQ("/**\n"
+ " * @returns {string} jsdoc line 12\n"
+ " */",
format("/** @returns {string} jsdoc line 12 */",
getGoogleJSStyleWithColumns(20)));
// FIXME: this overcounts the */ as a continuation of the 12 when breaking.
// Related to the FIXME in BreakableBlockComment::getRangeLength.
EXPECT_EQ("/**\n"
- " * @returns\n"
- " * {string}\n"
- " * jsdoc line\n"
+ " * @returns {string}\n"
+ " * jsdoc line line\n"
" * 12\n"
" */",
- format("/** @returns {string} jsdoc line 12*/",
- getGoogleJSStyleWithColumns(20)));
+ format("/** @returns {string} jsdoc line line 12*/",
+ getGoogleJSStyleWithColumns(25)));
// Fix a multiline jsdoc comment ending in a comment pragma.
EXPECT_EQ("/**\n"
@@ -2038,27 +2039,32 @@ TEST_F(FormatTestJS, WrapAfterParen) {
TEST_F(FormatTestJS, JSDocAnnotations) {
verifyFormat("/**\n"
- " * @exports\n"
- " * {this.is.a.long.path.to.a.Type}\n"
+ " * @exports {this.is.a.long.path.to.a.Type}\n"
" */",
"/**\n"
" * @exports {this.is.a.long.path.to.a.Type}\n"
" */",
getGoogleJSStyleWithColumns(20));
verifyFormat("/**\n"
- " * @mods\n"
- " * {this.is.a.long.path.to.a.Type}\n"
+ " * @mods {this.is.a.long.path.to.a.Type}\n"
+ " */",
+ "/**\n"
+ " * @mods {this.is.a.long.path.to.a.Type}\n"
+ " */",
+ getGoogleJSStyleWithColumns(20));
+ verifyFormat("/**\n"
+ " * @mods {this.is.a.long.path.to.a.Type}\n"
" */",
"/**\n"
" * @mods {this.is.a.long.path.to.a.Type}\n"
" */",
getGoogleJSStyleWithColumns(20));
verifyFormat("/**\n"
- " * @param\n"
- " * {this.is.a.long.path.to.a.Type}\n"
+ " * @param {canWrap\n"
+ " * onSpace}\n"
" */",
"/**\n"
- " * @param {this.is.a.long.path.to.a.Type}\n"
+ " * @param {canWrap onSpace}\n"
" */",
getGoogleJSStyleWithColumns(20));
verifyFormat("/**\n"
@@ -2083,8 +2089,7 @@ TEST_F(FormatTestJS, JSDocAnnotations) {
" /**\n"
" * long long long\n"
" * long\n"
- " * @param\n"
- " * {this.is.a.long.path.to.a.Type}\n"
+ " * @param {this.is.a.long.path.to.a.Type}\n"
" * a\n"
" * long long long\n"
" * long long\n"
OpenPOWER on IntegriCloud