From fed7729dbb708ea2e1d138e79e20b9ec9bdbe3fd Mon Sep 17 00:00:00 2001 From: Kato Kazuyoshi Date: Tue, 22 Mar 2011 14:10:25 +0000 Subject: [scaladoc] Closes #4366. Review by pedrofurla. --- test/scaladoc/resources/Trac4366.scala | 8 ++++++ test/scaladoc/scala/html/HtmlFactoryTest.scala | 26 +++++++++++++++++++ test/scaladoc/scala/model/CommentFactoryTest.scala | 30 ++++++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 test/scaladoc/resources/Trac4366.scala (limited to 'test') diff --git a/test/scaladoc/resources/Trac4366.scala b/test/scaladoc/resources/Trac4366.scala new file mode 100644 index 0000000000..d117ffa903 --- /dev/null +++ b/test/scaladoc/resources/Trac4366.scala @@ -0,0 +1,8 @@ +class Trac4366 { + /** + * foo has been deprecated and will be removed in a future version of + * ScalaTest. Please call bar instead. + */ + @deprecated // deprecated in 1.0, remove in 1.4 + val foo: Option[String] = None +} diff --git a/test/scaladoc/scala/html/HtmlFactoryTest.scala b/test/scaladoc/scala/html/HtmlFactoryTest.scala index f0f1cd7e49..ecdbb3cf46 100644 --- a/test/scaladoc/scala/html/HtmlFactoryTest.scala +++ b/test/scaladoc/scala/html/HtmlFactoryTest.scala @@ -98,4 +98,30 @@ object Test extends Properties("HtmlFactory") { val files = createTemplates("Trac4306.scala") files("com/example/trac4306/foo/package$$Bar.html") != None } + + property("Trac #4366") = { + val files = createTemplates("Trac4366.scala") + files("Trac4366.html") match { + case node: scala.xml.Node => { + val comments = XMLUtil.stripGroup(node).descendant.flatMap { + case e: scala.xml.Elem => { + if (e.attribute("class").toString.contains("shortcomment")) { + Some(e) + } else { + None + } + } + case _ => None + } + + comments.exists { + (e) => { + val s = e.toString + s.contains("foo") && s.contains("") + } + } + } + case _ => false + } + } } diff --git a/test/scaladoc/scala/model/CommentFactoryTest.scala b/test/scaladoc/scala/model/CommentFactoryTest.scala index afe27dace0..25a91b1fa2 100644 --- a/test/scaladoc/scala/model/CommentFactoryTest.scala +++ b/test/scaladoc/scala/model/CommentFactoryTest.scala @@ -18,6 +18,9 @@ class Factory(val g: Global, val s: doc.Settings) def parseComment(s: String): Option[Inline] = strip(parse(s, "", scala.tools.nsc.util.NoPosition)) + + def createBody(s: String) = + parse(s, "", scala.tools.nsc.util.NoPosition).body } object Test extends Properties("CommentFactory") { @@ -95,4 +98,31 @@ object Test extends Properties("CommentFactory") { Text("\n"), HtmlTag(""))))))) ) + + property("Trac #4366 - body") = { + val body = factory.createBody( + """ + /** + * foo has been deprecated and will be removed in a future version. Please call bar instead. + */ + """ + ) + + body == Body(List(Paragraph(Chain(List( + Summary(Chain(List(Chain(List(HtmlTag(""), HtmlTag("foo"), Text(" has been deprecated and will be removed in a future version"))), Text(".")))), + Chain(List(Text(" Please call "), HtmlTag("bar"), Text(" instead."), HtmlTag(""), Text("\n"), Text(""))) + ))))) + } + + property("Trac #4366 - summary") = { + val body = factory.createBody( + """ + /** + * foo has been deprecated and will be removed in a future version. Please call bar instead. + */ + """ + ) + + body.summary == Some(Chain(List(Chain(List(HtmlTag(""), HtmlTag("foo"), Text(" has been deprecated and will be removed in a future version"))), Text(".")))) + } } -- cgit v1.2.3