diff options
author | Antoine Gourlay <antoine@gourlay.fr> | 2015-04-02 16:08:25 +0200 |
---|---|---|
committer | Antoine Gourlay <antoine@gourlay.fr> | 2015-04-02 19:13:34 +0200 |
commit | 83ea1250882108c82e0e47adbebca28f907de4f4 (patch) | |
tree | e20ed191105462abbde829b78e043ec2aceb65e5 /test | |
parent | 2ce7ead5390368a2a6b7534f0ebfa20805b79221 (diff) | |
download | scala-83ea1250882108c82e0e47adbebca28f907de4f4.tar.gz scala-83ea1250882108c82e0e47adbebca28f907de4f4.tar.bz2 scala-83ea1250882108c82e0e47adbebca28f907de4f4.zip |
fix scaladoc issue with parsing of empty tags
Consider the following code:
/**
* @see
* @deprecated
*/
object Foo
The comment parser properly parsed the body of the 'see' tag as
empty, but not the one of 'deprecated': it supposedly contains a single
character, a newline '\n', which is wrong.
This always happened to the last tag in the list; it is always appended
a new line (whether empty or not), which breaks formatting (and things
later on that test if a body is empty of not).
Diffstat (limited to 'test')
-rw-r--r-- | test/scaladoc/scalacheck/CommentFactoryTest.scala | 20 | ||||
-rw-r--r-- | test/scaladoc/scalacheck/HtmlFactoryTest.scala | 4 |
2 files changed, 21 insertions, 3 deletions
diff --git a/test/scaladoc/scalacheck/CommentFactoryTest.scala b/test/scaladoc/scalacheck/CommentFactoryTest.scala index ff64a25602..d30b78087c 100644 --- a/test/scaladoc/scalacheck/CommentFactoryTest.scala +++ b/test/scaladoc/scalacheck/CommentFactoryTest.scala @@ -24,8 +24,11 @@ class Factory(val g: Global, val s: doc.Settings) } } + def getComment(s: String): Comment = + parse(s, "", scala.tools.nsc.util.NoPosition, null) + def parseComment(s: String): Option[Inline] = - strip(parse(s, "", scala.tools.nsc.util.NoPosition, null)) + strip(getComment(s)) def createBody(s: String) = parse(s, "", scala.tools.nsc.util.NoPosition, null).body @@ -166,4 +169,19 @@ object Test extends Properties("CommentFactory") { } } + property("Empty parameter text should be empty") = { + // used to fail with + // body == Body(List(Paragraph(Chain(List(Summary(Text('\n'))))))) + factory.getComment( + """ +/** + * @deprecated + */ + """).deprecated match { + case Some(Body(l)) if l.isEmpty => true + case other => + println(other) + false + } + } } diff --git a/test/scaladoc/scalacheck/HtmlFactoryTest.scala b/test/scaladoc/scalacheck/HtmlFactoryTest.scala index 51633be440..6a6b1f8901 100644 --- a/test/scaladoc/scalacheck/HtmlFactoryTest.scala +++ b/test/scaladoc/scalacheck/HtmlFactoryTest.scala @@ -685,7 +685,7 @@ object Test extends Properties("HtmlFactory") { case node: scala.xml.Node => { val s = node.toString s.contains("<h6>Author:</h6>") && - s.contains("<p>The Only Author\n</p>") + s.contains("<p>The Only Author</p>") } case _ => false } @@ -699,7 +699,7 @@ object Test extends Properties("HtmlFactory") { val s = node.toString s.contains("<h6>Authors:</h6>") && s.contains("<p>The First Author</p>") && - s.contains("<p>The Second Author\n</p>") + s.contains("<p>The Second Author</p>") } case _ => false } |