diff options
Diffstat (limited to 'dottydoc/jvm')
-rw-r--r-- | dottydoc/jvm/src/dotty/tools/dottydoc/DottyDoc.scala | 8 | ||||
-rw-r--r-- | dottydoc/jvm/test/CompilerTest.scala | 47 | ||||
-rw-r--r-- | dottydoc/jvm/test/TestCommentParsing.scala | 9 | ||||
-rw-r--r-- | dottydoc/jvm/test/WhitelistedStdLib.scala | 12 |
4 files changed, 67 insertions, 9 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) } |