diff options
author | Szymon Świstun <sswistun@virtuslab.com> | 2020-02-11 15:57:29 +0100 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-02-12 13:13:18 +0100 |
commit | af9697cbd2eb1a26c8a07d191ca6360d416a1666 (patch) | |
tree | dcb910792ba09457e7c52b64115d7215a2fa7d9b /plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt | |
parent | 50e711d24b517bc93c37d89f258c9dafaa038ad1 (diff) | |
download | dokka-af9697cbd2eb1a26c8a07d191ca6360d416a1666.tar.gz dokka-af9697cbd2eb1a26c8a07d191ca6360d416a1666.tar.bz2 dokka-af9697cbd2eb1a26c8a07d191ca6360d416a1666.zip |
kotlin-as-java fixed
Diffstat (limited to 'plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt')
-rw-r--r-- | plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt | 53 |
1 files changed, 49 insertions, 4 deletions
diff --git a/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt index c0833293..6186283f 100644 --- a/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt +++ b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt @@ -1,6 +1,5 @@ package kotlinAsJavaPlugin -import junit.framework.Assert.fail import org.jetbrains.dokka.pages.ContentGroup import org.jetbrains.dokka.pages.ContentPage import org.jetbrains.dokka.pages.ContentTable @@ -10,6 +9,8 @@ import testApi.testRunner.AbstractCoreTest class KotlinAsJavaPluginTest : AbstractCoreTest() { + fun fail(msg: String) = assert(false) { msg } + @Test fun topLevelTest() { val configuration = dokkaConfiguration { @@ -37,7 +38,7 @@ class KotlinAsJavaPluginTest : AbstractCoreTest() { cleanupOutput = true ) { pagesGenerationStage = { root -> - val content = (root.children.firstOrNull()?.children?.firstOrNull() as? ContentPage )?.content ?: run { + val content = (root.children.firstOrNull()?.children?.firstOrNull() as? ContentPage)?.content ?: run { fail("Either children or content is null") } @@ -92,7 +93,51 @@ class KotlinAsJavaPluginTest : AbstractCoreTest() { } } - private fun <T> Collection<T>.assertCount(n: Int) = - assert(count() == n) { "Expected $n, got ${count()}" } + @Test + fun kotlinAndJavaTest() { + val configuration = dokkaConfiguration { + passes { + pass { + sourceRoots = listOf("src/") + } + } + } + testInline( + """ + |/src/main/kotlin/kotlinAsJavaPlugin/Test.kt + |package kotlinAsJavaPlugin + | + |fun testF(i: Int) = i + |/src/main/kotlin/kotlinAsJavaPlugin/TestJ.java + |package kotlinAsJavaPlugin + | + |class TestJ { + | int testF(int i) { return i; } + |} + """, + configuration, + cleanupOutput = true + ) { + pagesGenerationStage = { root -> + val classes = root.children.first().children.associateBy { it.name } + classes.values.assertCount(2, "Class count: ") + + classes["TestKt"].let { + it?.children.orEmpty().assertCount(1, "(Kotlin) TestKt members: ") + it!!.children.first() + .let { assert(it.name == "testF") { "(Kotlin) Expected method name: testF, got: ${it.name}" } } + } + + classes["TestJ"].let { + it?.children.orEmpty().assertCount(1, "(Java) TestJ members: ") + it!!.children.first() + .let { assert(it.name == "testF") { "(Java) Expected method name: testF, got: ${it.name}" } } + } + } + } + } + + private fun <T> Collection<T>.assertCount(n: Int, prefix: String = "") = + assert(count() == n) { "${prefix}Expected $n, got ${count()}" } }
\ No newline at end of file |