aboutsummaryrefslogtreecommitdiff
path: root/doc-tool/test
diff options
context:
space:
mode:
authorValthor Halldorsson <halldorsson.v@gmail.com>2017-03-08 21:59:56 +0000
committerValthor Halldorsson <halldorsson.v@gmail.com>2017-03-10 09:22:51 +0000
commite7fe9df3c14df0e5ccd88440dbd49a9dce65d48f (patch)
tree4b6b099f0560a4cc0cff92c838440500b38ad691 /doc-tool/test
parent3c4d29eabaa71c30ccc2c7b62517d771d6f9d8f5 (diff)
downloaddotty-e7fe9df3c14df0e5ccd88440dbd49a9dce65d48f.tar.gz
dotty-e7fe9df3c14df0e5ccd88440dbd49a9dce65d48f.tar.bz2
dotty-e7fe9df3c14df0e5ccd88440dbd49a9dce65d48f.zip
consolidate entity serialization into single class
- refactored JavaEntity to be DRY with respect to repeating the serialization of fields shared by many types of entities - added tests
Diffstat (limited to 'doc-tool/test')
-rw-r--r--doc-tool/test/JavaConverterTest.scala111
1 files changed, 111 insertions, 0 deletions
diff --git a/doc-tool/test/JavaConverterTest.scala b/doc-tool/test/JavaConverterTest.scala
new file mode 100644
index 000000000..4f1dec5e9
--- /dev/null
+++ b/doc-tool/test/JavaConverterTest.scala
@@ -0,0 +1,111 @@
+package dotty.tools
+package dottydoc
+
+import org.junit.Test
+import org.junit.Assert._
+import model.{
+ Entity,
+ Members,
+ SuperTypes,
+ Modifiers,
+ TypeParams,
+ Constructors => MConstructors,
+ Companion,
+ ReturnValue,
+ ImplicitlyAddedEntity,
+ TypeAlias,
+ Trait,
+ Def,
+ NonEntity
+}
+import model.references.{ConstantReference, TypeReference, NoLink}
+import model.comment.Comment
+import dotty.tools.dotc.core.Symbols.NoSymbol
+import _root_.java.util.{Optional => JOptional, Map => JMap}
+
+class JavaConverterTest {
+ import model.JavaConverters._
+
+ @Test def entityConversions = {
+ trait TestEntity extends Entity {
+ def symbol = NoSymbol
+
+ def name = "test"
+
+ def kind = "ent"
+
+ def path = "path" :: "to" :: "test" :: Nil
+
+ def comment = Some(new Comment("", "", List(), List(), None, Map(), Map(), Map(), None, None, List(), None, List(), List(), None, None, Map(), Map(), Map(), List()))
+
+ def annotations = List("test")
+
+ def parent = NonEntity
+
+ }
+ trait TestMembers extends TestEntity with Members {
+ def members = new TestEntity{} :: Nil
+ }
+ trait TestSuperTypes extends TestEntity with SuperTypes {
+ def superTypes = new NoLink("title", "query") :: Nil
+ }
+ trait TestModifiers extends TestEntity with Modifiers {
+ def modifiers = "private" :: Nil
+ }
+ trait TestTypeParams extends TestEntity with TypeParams {
+ def typeParams = "String" :: "String" :: Nil
+ }
+ trait TestConstructors extends TestEntity with MConstructors {
+ def constructors = List(List())
+ }
+ trait TestCompanion extends TestEntity with Companion {
+ def companionPath = "path" :: "to" :: "companion" :: Nil
+ def companionPath_=(xs: List[String]) = Unit
+ }
+ trait TestReturnValue extends TestEntity with ReturnValue {
+ def returnValue =
+ new TypeReference("String", new NoLink("title", "target"), List())
+ }
+ trait TestImplicitlyAddedEntity
+ extends TestEntity
+ with ImplicitlyAddedEntity {
+ def implicitlyAddedFrom =
+ Some(
+ new TypeReference("String", new NoLink("title", "target"), List()))
+ }
+ trait TestTypeAlias extends TestTypeParams with TestModifiers with TypeAlias {
+ override val kind = "type"
+ def alias = None
+ }
+ trait TestDef extends TestModifiers with TestTypeParams with TestImplicitlyAddedEntity {
+ def paramLists = List()
+ }
+ trait TestTrait extends TestModifiers with TestTypeParams with TestSuperTypes with TestMembers with TestCompanion {
+ def traitParams = List()
+ }
+ val ent = new TestEntity {}
+ val members = new TestMembers {}
+ val superTypes = new TestSuperTypes {}
+ val modifiers = new TestModifiers {}
+ val typeParams = new TestTypeParams {}
+ val constructors = new TestConstructors {}
+ val companion = new TestCompanion {}
+ val returnValue = new TestReturnValue {}
+ val implicitlyAddedEntity = new TestImplicitlyAddedEntity {}
+ val typeAlias = new TestTypeAlias {}
+ val df = new TestDef {}
+ val trt = new TestTrait {}
+ val ent_serialized = ent.asJava()
+ val members_serialized = members.asJava()
+ val superTypes_serialized = superTypes.asJava()
+ val modifiers_serialized = modifiers.asJava()
+ val typeParams_serialized = typeParams.asJava()
+ val constructors_serialized = constructors.asJava()
+ val companion_serialized = companion.asJava()
+ val returnValue_serialized = returnValue.asJava()
+ val implicitlyAddedEntity_serialized = implicitlyAddedEntity.asJava()
+ val typeAlias_serialized = typeAlias.asJava()
+ val def_serialized = df.asJava()
+ val trait_serialized = trt.asJava()
+ }
+}