aboutsummaryrefslogtreecommitdiff
path: root/test/test/DottyDocTest.scala
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2016-04-07 08:27:43 +0200
committerFelix Mulder <felix.mulder@gmail.com>2016-04-07 08:57:05 +0200
commitf43f520a1a6e60d4a6020af97c52dd6c43ea75cd (patch)
tree2d746b4de308c1fc580e00704254b0b843ede5c4 /test/test/DottyDocTest.scala
parent844683edb78f45bf37949bd923f56fc98a68c837 (diff)
downloaddotty-f43f520a1a6e60d4a6020af97c52dd6c43ea75cd.tar.gz
dotty-f43f520a1a6e60d4a6020af97c52dd6c43ea75cd.tar.bz2
dotty-f43f520a1a6e60d4a6020af97c52dd6c43ea75cd.zip
Add binding between Symbol and Untyped tree in base context
This commit also adds a printer for use by dottydoc.
Diffstat (limited to 'test/test/DottyDocTest.scala')
-rw-r--r--test/test/DottyDocTest.scala30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/test/DottyDocTest.scala b/test/test/DottyDocTest.scala
new file mode 100644
index 000000000..eed5d6cd0
--- /dev/null
+++ b/test/test/DottyDocTest.scala
@@ -0,0 +1,30 @@
+package test
+
+import dotty.tools.dotc.ast.Trees._
+import dotty.tools.dotc.core.Contexts.Context
+
+trait DottyDocTest extends DottyTest {
+ def checkDocString(actual: Option[String], expected: String): Unit = actual match {
+ case Some(str) =>
+ assert(str == expected, s"""Docstring: "$str" didn't match expected "$expected"""")
+ case None =>
+ assert(false, s"""No docstring found, expected: "$expected"""")
+ }
+
+ def expectNoDocString(doc: Option[String]): Unit =
+ doc.fold(()) { d => assert(false, s"""Expected not to find a docstring, but found: "$d"""") }
+
+ def defaultAssertion: PartialFunction[Any, Unit] = {
+ case t: Tree[Untyped] =>
+ assert(false, s"Couldn't match resulting AST to expected AST in: ${t.show}")
+ case x =>
+ assert(false, s"Couldn't match resulting AST to expected AST in: $x")
+ }
+
+ def checkFrontend(source: String)(docAssert: PartialFunction[Tree[Untyped], Unit]) = {
+ checkCompile("frontend", source) { (_, ctx) =>
+ implicit val c = ctx
+ (docAssert orElse defaultAssertion)(ctx.compilationUnit.untpdTree)
+ }
+ }
+}