aboutsummaryrefslogtreecommitdiff
path: root/dottydoc/test/BaseTest.scala
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2016-08-09 18:42:54 +0200
committerFelix Mulder <felix.mulder@gmail.com>2016-08-19 15:37:33 +0200
commit5cd1d51c3cb44b2c9b2c1abd433da50a00e5219e (patch)
tree2f87a0e18b2c44cce28a2b424f2b3b1e97ac1732 /dottydoc/test/BaseTest.scala
parent079e3db0f157ee6eae9e8a34b3bbf7a75cdaa929 (diff)
downloaddotty-5cd1d51c3cb44b2c9b2c1abd433da50a00e5219e.tar.gz
dotty-5cd1d51c3cb44b2c9b2c1abd433da50a00e5219e.tar.bz2
dotty-5cd1d51c3cb44b2c9b2c1abd433da50a00e5219e.zip
Remove client from dottydoc - no more Scala.JS deps!
Diffstat (limited to 'dottydoc/test/BaseTest.scala')
-rw-r--r--dottydoc/test/BaseTest.scala58
1 files changed, 58 insertions, 0 deletions
diff --git a/dottydoc/test/BaseTest.scala b/dottydoc/test/BaseTest.scala
new file mode 100644
index 000000000..0c6fad1c8
--- /dev/null
+++ b/dottydoc/test/BaseTest.scala
@@ -0,0 +1,58 @@
+package dotty.tools
+package dottydoc
+
+import dotc.core.Contexts
+import Contexts.{ Context, ContextBase, FreshContext }
+import dotc.util.SourceFile
+import dotc.core.Phases.Phase
+import dotc.typer.FrontEnd
+import dottydoc.core.DocASTPhase
+
+trait DottyTest {
+ dotty.tools.dotc.parsing.Scanners // initialize keywords
+
+ implicit var ctx: FreshContext = {
+ val base = new ContextBase
+ import base.settings._
+ val ctx = base.initialCtx.fresh
+ ctx.setSetting(ctx.settings.language, List("Scala2"))
+ ctx.setSetting(ctx.settings.YkeepComments, true)
+ ctx.setSetting(ctx.settings.YDocNoWrite, true)
+ base.initialize()(ctx)
+ ctx
+ }
+
+ private def compilerWithChecker(assertion: DocASTPhase => Unit) = new DottyDocCompiler {
+ private[this] val docPhase = new DocASTPhase
+
+ 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 checkSource(source: String)(assertion: DocASTPhase => Unit): Unit = {
+ val c = compilerWithChecker(assertion)
+ c.rootContext(ctx)
+ val run = c.newRun
+ run.compile(source)
+ }
+
+ def checkFiles(sources: List[String])(assertion: DocASTPhase => Unit): Unit = {
+ val c = compilerWithChecker(assertion)
+ c.rootContext(ctx)
+ val run = c.newRun
+ run.compile(sources)
+ }
+
+ def checkSources(sourceFiles: List[SourceFile])(assertion: DocASTPhase => Unit): Unit = {
+ val c = compilerWithChecker(assertion)
+ c.rootContext(ctx)
+ val run = c.newRun
+ run.compileSources(sourceFiles)
+ }
+}