aboutsummaryrefslogtreecommitdiff
path: root/dottydoc/jvm/test
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2016-05-05 11:28:51 +0200
committerFelix Mulder <felix.mulder@gmail.com>2016-08-19 15:37:22 +0200
commit29cf43bca7e478f290e7c39a05ce7e8bcb218d3d (patch)
tree700e755e13f296728094831d6ab204df12d017df /dottydoc/jvm/test
parentb4622aabd0ebd6929639c9cfcd3c7845a250598f (diff)
downloaddotty-29cf43bca7e478f290e7c39a05ce7e8bcb218d3d.tar.gz
dotty-29cf43bca7e478f290e7c39a05ce7e8bcb218d3d.tar.bz2
dotty-29cf43bca7e478f290e7c39a05ce7e8bcb218d3d.zip
Add JUnit test structure for testing the DocPhase
Diffstat (limited to 'dottydoc/jvm/test')
-rw-r--r--dottydoc/jvm/test/CompilerTest.scala47
-rw-r--r--dottydoc/jvm/test/TestCommentParsing.scala9
-rw-r--r--dottydoc/jvm/test/WhitelistedStdLib.scala12
3 files changed, 63 insertions, 5 deletions
diff --git a/dottydoc/jvm/test/CompilerTest.scala b/dottydoc/jvm/test/CompilerTest.scala
new file mode 100644
index 000000000..4cafc72e0
--- /dev/null
+++ b/dottydoc/jvm/test/CompilerTest.scala
@@ -0,0 +1,47 @@
+package dotty.tools
+package dottydoc
+
+import dotc.core.Contexts
+import Contexts.{ Context, ContextBase }
+import dotc.core.Phases.Phase
+import dotc.typer.FrontEnd
+import dottydoc.core.Phases.DocPhase
+
+trait DottyTest {
+ dotty.tools.dotc.parsing.Scanners // initialize keywords
+
+ implicit var ctx: Contexts.Context = {
+ val base = new ContextBase
+ import base.settings._
+ val ctx = base.initialCtx.fresh
+ ctx.setSetting(ctx.settings.YkeepComments, true)
+ base.initialize()(ctx)
+ ctx
+ }
+
+ private def compilerWithChecker(assertion: DocPhase => Unit) = new DottyDocCompiler {
+ val docPhase = new DocPhase
+ override def phases =
+ List(new FrontEnd) ::
+ List(docPhase) ::
+ List(new Phase {
+ def phaseName = "assertionPhase"
+ override def run(implicit ctx: Context): Unit = assertion(docPhase)
+ }) ::
+ Nil
+ }
+
+ def checkCompile(source: String)(assertion: DocPhase => Unit): Unit = {
+ val c = compilerWithChecker(assertion)
+ c.rootContext(ctx)
+ val run = c.newRun
+ run.compile(source)
+ }
+
+ def checkCompile(sources:List[String])(assertion: DocPhase => Unit): Unit = {
+ val c = compilerWithChecker(assertion)
+ c.rootContext(ctx)
+ val run = c.newRun
+ run.compile(sources)
+ }
+}
diff --git a/dottydoc/jvm/test/TestCommentParsing.scala b/dottydoc/jvm/test/TestCommentParsing.scala
new file mode 100644
index 000000000..16e855957
--- /dev/null
+++ b/dottydoc/jvm/test/TestCommentParsing.scala
@@ -0,0 +1,9 @@
+package dotty.tools
+package dottydoc
+
+import org.junit.Test
+import org.junit.Assert._
+
+class TestWhitelistedCollections extends DottyTest {
+ @Test def test = assert(false)
+}
diff --git a/dottydoc/jvm/test/WhitelistedStdLib.scala b/dottydoc/jvm/test/WhitelistedStdLib.scala
index 8ba8f2b89..2ab832870 100644
--- a/dottydoc/jvm/test/WhitelistedStdLib.scala
+++ b/dottydoc/jvm/test/WhitelistedStdLib.scala
@@ -3,10 +3,11 @@ package dottydoc
import scala.io.Source
-object WhitelistedStdLib extends DottyDoc {
- override def main(args: Array[String]) = {
+object WhitelistedStandardLib extends DottyDoc {
+ val files: Array[String] = {
val whitelist = "../../test/dotc/scala-collections.whitelist"
- val stdlibFiles = Source.fromFile(whitelist, "UTF8")
+
+ Source.fromFile(whitelist, "UTF8")
.getLines()
.map(_.trim) // allow identation
.filter(!_.startsWith("#")) // allow comment lines prefixed by #
@@ -15,7 +16,8 @@ object WhitelistedStdLib extends DottyDoc {
.filterNot(_.endsWith("package.scala"))
.map("../." + _)
.toArray
-
- super.main("-language:Scala2" +: stdlibFiles)
}
+
+ override def main(args: Array[String]) =
+ super.main("-language:Scala2" +: files)
}