diff options
Diffstat (limited to 'test/src')
-rw-r--r-- | test/src/TestAPI.kt | 12 | ||||
-rw-r--r-- | test/src/model/KotlinAsJavaTest.kt | 32 |
2 files changed, 42 insertions, 2 deletions
diff --git a/test/src/TestAPI.kt b/test/src/TestAPI.kt index 59b6495b..c4be6623 100644 --- a/test/src/TestAPI.kt +++ b/test/src/TestAPI.kt @@ -16,6 +16,7 @@ import kotlin.test.fail public fun verifyModel(vararg roots: ContentRoot, withJdk: Boolean = false, withKotlinRuntime: Boolean = false, + packageDocumentationBuilder: PackageDocumentationBuilder? = null, verifier: (DocumentationModule) -> Unit) { val messageCollector = object : MessageCollector { override fun report(severity: CompilerMessageSeverity, message: String, location: CompilerMessageLocation) { @@ -46,7 +47,9 @@ public fun verifyModel(vararg roots: ContentRoot, addRoots(roots.toList()) } val options = DocumentationOptions(includeNonPublic = true, skipEmptyPackages = false, sourceLinks = listOf<SourceLinkDefinition>()) - val documentation = buildDocumentationModule(environment, "test", options, logger = DokkaConsoleLogger) + val documentation = buildDocumentationModule(environment, "test", options, + packageDocumentationBuilder = packageDocumentationBuilder, + logger = DokkaConsoleLogger) verifier(documentation) Disposer.dispose(environment) } @@ -54,8 +57,13 @@ public fun verifyModel(vararg roots: ContentRoot, public fun verifyModel(source: String, withJdk: Boolean = false, withKotlinRuntime: Boolean = false, + packageDocumentationBuilder: PackageDocumentationBuilder? = null, verifier: (DocumentationModule) -> Unit) { - verifyModel(contentRootFromPath(source), withJdk = withJdk, withKotlinRuntime = withKotlinRuntime, verifier = verifier) + verifyModel(contentRootFromPath(source), + withJdk = withJdk, + withKotlinRuntime = withKotlinRuntime, + packageDocumentationBuilder = packageDocumentationBuilder, + verifier = verifier) } public fun verifyPackageMember(kotlinSource: String, diff --git a/test/src/model/KotlinAsJavaTest.kt b/test/src/model/KotlinAsJavaTest.kt new file mode 100644 index 00000000..25ee5fad --- /dev/null +++ b/test/src/model/KotlinAsJavaTest.kt @@ -0,0 +1,32 @@ +package org.jetbrains.dokka.tests + +import org.jetbrains.dokka.DocumentationModule +import org.jetbrains.dokka.DocumentationNode +import org.jetbrains.dokka.KotlinAsJavaDocumentationBuilder +import org.junit.Test +import kotlin.test.assertEquals + +class KotlinAsJavaTest { + @Test fun function() { + verifyModelAsJava("test/data/functions/function.kt") { model -> + val pkg = model.members.single() + + val facadeClass = pkg.members.single { it.name == "FunctionKt" } + assertEquals(DocumentationNode.Kind.Class, facadeClass.kind) + + val fn = facadeClass.members.single() + assertEquals("fn", fn.name) + assertEquals(DocumentationNode.Kind.CompanionObjectFunction, fn.kind) + } + } +} + +fun verifyModelAsJava(source: String, + withJdk: Boolean = false, + withKotlinRuntime: Boolean = false, + verifier: (DocumentationModule) -> Unit) { + verifyModel(source, + withJdk = withJdk, withKotlinRuntime = withKotlinRuntime, + packageDocumentationBuilder = KotlinAsJavaDocumentationBuilder(), + verifier = verifier) +} |