diff options
author | Gilles Dubochet <gilles.dubochet@epfl.ch> | 2010-09-21 12:42:12 +0000 |
---|---|---|
committer | Gilles Dubochet <gilles.dubochet@epfl.ch> | 2010-09-21 12:42:12 +0000 |
commit | 6b957d04557b6c72dd77676e246f4541442f182d (patch) | |
tree | 0dfde148e710d6b5aeb358e5b1d60c0c5e0aa32b | |
parent | feb435cc0ac77d158ccd9a119ee248fe49c12529 (diff) | |
download | scala-6b957d04557b6c72dd77676e246f4541442f182d.tar.gz scala-6b957d04557b6c72dd77676e246f4541442f182d.tar.bz2 scala-6b957d04557b6c72dd77676e246f4541442f182d.zip |
[scaladoc] Adds some simple tests for Scaladoc ...
[scaladoc] Adds some simple tests for Scaladoc (using Scalacheck).
Contributed by Kato Kazuyosh. No review.
-rw-r--r-- | build.xml | 11 | ||||
-rw-r--r-- | test/scaladoc/model/CommentFactoryTest.scala | 68 |
2 files changed, 78 insertions, 1 deletions
@@ -1588,7 +1588,16 @@ BOOTRAPING TEST AND TEST SUITE </partest> </target> - <target name="test.done" depends="test.suite, test.continuations.suite, test.stability"/> + <target name="test.scaladoc" depends="pack.done"> + <partest erroronfailed="yes" scalacopts="${scalac.args.optimise}"> + <compilationpath> + <path refid="pack.classpath"/> + </compilationpath> + <scalachecktests dir="test/scaladoc" includes="**/*.scala"/> + </partest> + </target> + + <target name="test.done" depends="test.suite, test.continuations.suite, test.scaladoc, test.stability"/> <!-- =========================================================================== DISTRIBUTION diff --git a/test/scaladoc/model/CommentFactoryTest.scala b/test/scaladoc/model/CommentFactoryTest.scala new file mode 100644 index 0000000000..20b52b91f7 --- /dev/null +++ b/test/scaladoc/model/CommentFactoryTest.scala @@ -0,0 +1,68 @@ +import org.scalacheck._ + +import scala.tools.nsc.Global +import scala.tools.nsc.doc +import scala.tools.nsc.doc.model.comment._ + +class Factory(val g: Global, val s: doc.Settings) + extends doc.model.ModelFactory(g, s) { + thisFactory: Factory with CommentFactory with doc.model.TreeFactory => + + def strip(c: Comment): Option[Inline] = { + c.body match { + case Body(List(Paragraph(Chain(List(Summary(inner)))))) => Some(inner) + case _ => None + } + } + + def parseComment(s: String): Option[Inline] = + strip(parse(s, "", scala.tools.nsc.util.NoPosition)) +} + +object Test extends Properties("CommentFactory") { + val factory = { + val settings = new doc.Settings((str: String) => {}) + val reporter = new scala.tools.nsc.reporters.ConsoleReporter(settings) + val g = new Global(settings, reporter) + (new Factory(g, settings) with CommentFactory with doc.model.TreeFactory) + } + + def parse(src: String, dst: Inline) = { + factory.parseComment(src) match { + case Some(inline) => + inline == dst + case _ => + false + } + } + + property("parse") = parse( + "/** One two three */", + Text("One two three") + ) + property("parse") = parse( + "/** One `two` three */", + Chain(List(Text("One "), Monospace("two"), Text(" three"))) + ) + + property("parse") = parse( + """ +/** One two + * three */""", + Text("One two\nthree") + ) + property("parse") = parse( + """ +/** One `two` + * three */""", + Chain(List(Text("One "), Monospace("two"), Text("\nthree"))) + ) + + property("parse") = parse( + """ +/** One `two` + * three */""", + Chain(List(Text("One "), Monospace("two"), Text("\n three"))) + ) + +} |