aboutsummaryrefslogtreecommitdiff
path: root/plugins/kotlin-as-java/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/kotlin-as-java/src/test')
-rw-r--r--plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt107
1 files changed, 107 insertions, 0 deletions
diff --git a/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt
index 96446201..ba513bf2 100644
--- a/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt
+++ b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt
@@ -1,9 +1,11 @@
package kotlinAsJavaPlugin
+import org.jetbrains.dokka.model.dfs
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest
import org.jetbrains.kotlin.utils.addToStdlib.cast
import org.junit.jupiter.api.Test
+import matchers.content.*
class KotlinAsJavaPluginTest : AbstractCoreTest() {
@@ -130,6 +132,111 @@ class KotlinAsJavaPluginTest : AbstractCoreTest() {
}
}
+ @Test
+ fun `public kotlin properties should have a getter with same visibilities`(){
+ val configuration = dokkaConfiguration {
+ sourceSets {
+ sourceSet {
+ sourceRoots = listOf("src/")
+ }
+ }
+ }
+ testInline(
+ """
+ |/src/main/kotlin/kotlinAsJavaPlugin/Test.kt
+ |package kotlinAsJavaPlugin
+ |
+ |class Test {
+ | public val publicProperty: String = ""
+ |}
+ """,
+ configuration,
+ cleanupOutput = true
+ ) {
+ pagesTransformationStage = { rootPageNode ->
+ val propertyGetter = rootPageNode.dfs { it is MemberPageNode && it.name == "getPublicProperty" } as? MemberPageNode
+ assert(propertyGetter != null)
+ propertyGetter!!.content.assertNode {
+ group {
+ header(1) {
+ +"getPublicProperty"
+ }
+ }
+ divergentGroup {
+ divergentInstance {
+ divergent {
+ group {
+ +"final"
+ group {
+ link {
+ +" String"
+ }
+ }
+ group {
+ link {
+ +"getPublicProperty"
+ }
+ +"()"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ @Test
+ fun `java properties should keep its modifiers`(){
+ val configuration = dokkaConfiguration {
+ sourceSets {
+ sourceSet {
+ sourceRoots = listOf("src/")
+ }
+ }
+ }
+ testInline(
+ """
+ |/src/main/kotlin/kotlinAsJavaPlugin/TestJ.java
+ |package kotlinAsJavaPlugin
+ |
+ |class TestJ {
+ | public Int publicProperty = 1;
+ |}
+ """,
+ configuration,
+ cleanupOutput = true
+ ) {
+ pagesGenerationStage = { root ->
+ val testClass = root.dfs { it.name == "TestJ" } as? ClasslikePageNode
+ assert(testClass != null)
+ (testClass!!.content as ContentGroup).children.last().assertNode {
+ group {
+ header(2){
+ +"Properties"
+ }
+ table {
+ group {
+ link {
+ +"publicProperty"
+ }
+ platformHinted {
+ group {
+ +"public Int"
+ link {
+ +"publicProperty"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
private fun <T> Collection<T>.assertCount(n: Int, prefix: String = "") =
assert(count() == n) { "${prefix}Expected $n, got ${count()}" }