diff options
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 |