From b643bf6f4b4c29676ce3301d92b7880b268d6722 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 5 Nov 2015 15:51:23 +0100 Subject: add tests; fixes related to qualified names of types --- javadoc/src/test/data/obj.kt | 7 ++++++ javadoc/src/test/data/types.kt | 4 ++++ javadoc/src/test/kotlin/JavadocTest.kt | 44 ++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 javadoc/src/test/data/obj.kt create mode 100644 javadoc/src/test/data/types.kt create mode 100644 javadoc/src/test/kotlin/JavadocTest.kt (limited to 'javadoc/src/test') diff --git a/javadoc/src/test/data/obj.kt b/javadoc/src/test/data/obj.kt new file mode 100644 index 00000000..1d10a422 --- /dev/null +++ b/javadoc/src/test/data/obj.kt @@ -0,0 +1,7 @@ +package foo + +class O { + companion object { + + } +} diff --git a/javadoc/src/test/data/types.kt b/javadoc/src/test/data/types.kt new file mode 100644 index 00000000..55be6058 --- /dev/null +++ b/javadoc/src/test/data/types.kt @@ -0,0 +1,4 @@ +package foo + +fun foo(x: Int, o: Any): String { +} diff --git a/javadoc/src/test/kotlin/JavadocTest.kt b/javadoc/src/test/kotlin/JavadocTest.kt new file mode 100644 index 00000000..1ac7069b --- /dev/null +++ b/javadoc/src/test/kotlin/JavadocTest.kt @@ -0,0 +1,44 @@ +package org.jetbrains.dokka.javadoc + +import org.jetbrains.dokka.DokkaConsoleLogger +import org.jetbrains.dokka.tests.verifyModel +import org.junit.Test +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertNotNull +import kotlin.test.assertTrue + +class JavadocTest { + @Test fun testTypes() { + verifyModel("javadoc/src/test/data/types.kt", format = "javadoc", withJdk = true) { model -> + val doc = ModuleNodeAdapter(model, StandardReporter(DokkaConsoleLogger), "") + val classDoc = doc.classNamed("foo.TypesKt")!! + val method = classDoc.methods().find { it.name() == "foo" }!! + + val type = method.returnType() + assertFalse(type.asClassDoc().isIncluded) + assertEquals("java.lang.String", type.qualifiedTypeName()) + assertEquals("java.lang.String", type.asClassDoc().qualifiedName()) + + val params = method.parameters() + assertTrue(params[0].type().isPrimitive) + assertFalse(params[1].type().asClassDoc().isIncluded) + } + } + + @Test fun testObject() { + verifyModel("javadoc/src/test/data/obj.kt", format = "javadoc") { model -> + val doc = ModuleNodeAdapter(model, StandardReporter(DokkaConsoleLogger), "") + + val classDoc = doc.classNamed("foo.O") + assertNotNull(classDoc) + + val companionDoc = doc.classNamed("foo.O.Companion") + assertNotNull(companionDoc) + + val pkgDoc = doc.packageNamed("foo")!! + assertEquals(2, pkgDoc.allClasses().size) + } + } + +} -- cgit