aboutsummaryrefslogtreecommitdiff
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
parentb4622aabd0ebd6929639c9cfcd3c7845a250598f (diff)
downloaddotty-29cf43bca7e478f290e7c39a05ce7e8bcb218d3d.tar.gz
dotty-29cf43bca7e478f290e7c39a05ce7e8bcb218d3d.tar.bz2
dotty-29cf43bca7e478f290e7c39a05ce7e8bcb218d3d.zip
Add JUnit test structure for testing the DocPhase
-rw-r--r--dottydoc/jvm/src/dotty/tools/dottydoc/DottyDoc.scala8
-rw-r--r--dottydoc/jvm/test/CompilerTest.scala47
-rw-r--r--dottydoc/jvm/test/TestCommentParsing.scala9
-rw-r--r--dottydoc/jvm/test/WhitelistedStdLib.scala12
-rw-r--r--project/Build.scala4
-rw-r--r--project/plugins.sbt2
6 files changed, 71 insertions, 11 deletions
diff --git a/dottydoc/jvm/src/dotty/tools/dottydoc/DottyDoc.scala b/dottydoc/jvm/src/dotty/tools/dottydoc/DottyDoc.scala
index 428bc17d8..1fb93d961 100644
--- a/dottydoc/jvm/src/dotty/tools/dottydoc/DottyDoc.scala
+++ b/dottydoc/jvm/src/dotty/tools/dottydoc/DottyDoc.scala
@@ -31,10 +31,10 @@ class DottyDocCompiler extends Compiler {
List(new DocPhase) ::
Nil
- override def newRun(implicit ctx: Context): Run = {
- reset()
- new DocRun(this)(rootContext)
- }
+ override def newRun(implicit ctx: Context): Run = {
+ reset()
+ new DocRun(this)(rootContext)
+ }
}
class DocRun(comp: Compiler)(implicit ctx: Context) extends Run(comp)(ctx) {
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)
}
diff --git a/project/Build.scala b/project/Build.scala
index 6b9939a34..add3ebecb 100644
--- a/project/Build.scala
+++ b/project/Build.scala
@@ -268,7 +268,6 @@ object DottyInjectedPlugin extends AutoPlugin {
.jsSettings(
libraryDependencies ++= Seq(
"org.scala-js" %%% "scalajs-dom" % "0.9.0",
- "com.github.benhutchison" %%% "microjson" % "1.3",
"com.github.benhutchison" %%% "prickle" % "1.1.10",
"com.lihaoyi" %%% "scalatags" % "0.5.5"
)
@@ -287,7 +286,8 @@ object DottyInjectedPlugin extends AutoPlugin {
libraryDependencies ++= Seq(
"org.scala-js" % "scalajs-dom_sjs0.6_2.11" % "0.9.0",
"com.github.benhutchison" %% "prickle" % "1.1.10",
- "com.lihaoyi" %% "scalatags" % "0.5.5"
+ "com.lihaoyi" %% "scalatags" % "0.5.5",
+ "com.novocode" % "junit-interface" % "0.11" % "test"
),
// enable improved incremental compilation algorithm
diff --git a/project/plugins.sbt b/project/plugins.sbt
index 57bd46581..8ac4d69bf 100644
--- a/project/plugins.sbt
+++ b/project/plugins.sbt
@@ -8,3 +8,5 @@ addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "0.8.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.8")
+
+addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.3.5")