aboutsummaryrefslogtreecommitdiff
path: root/plugins/kotlin-as-java/src/test/kotlin/JvmFieldTest.kt
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/kotlin-as-java/src/test/kotlin/JvmFieldTest.kt')
-rw-r--r--plugins/kotlin-as-java/src/test/kotlin/JvmFieldTest.kt61
1 files changed, 61 insertions, 0 deletions
diff --git a/plugins/kotlin-as-java/src/test/kotlin/JvmFieldTest.kt b/plugins/kotlin-as-java/src/test/kotlin/JvmFieldTest.kt
index 99ea017b..f0c44530 100644
--- a/plugins/kotlin-as-java/src/test/kotlin/JvmFieldTest.kt
+++ b/plugins/kotlin-as-java/src/test/kotlin/JvmFieldTest.kt
@@ -1,11 +1,14 @@
package kotlinAsJavaPlugin
import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
+import org.jetbrains.dokka.model.AdditionalModifiers
+import org.jetbrains.dokka.model.ExtraModifiers
import org.jetbrains.dokka.model.JavaVisibility
import org.junit.jupiter.api.Test
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
import kotlin.test.assertNull
+import kotlin.test.assertTrue
class JvmFieldTest : BaseAbstractTest() {
val configuration = dokkaConfiguration {
@@ -106,4 +109,62 @@ class JvmFieldTest : BaseAbstractTest() {
}
}
}
+
+ @Test
+ fun `enum jvmfield property should have no getters`(){
+ testInline(
+ """
+ |/src/main/kotlin/kotlinAsJavaPlugin/sample.kt
+ |package kotlinAsJavaPlugin
+ |enum class MyEnum {
+ | ITEM;
+ |
+ | @JvmField
+ | val property: String = TODO()
+ |}
+ """.trimMargin(),
+ configuration,
+ ) {
+ documentablesTransformationStage = { module ->
+ val classLike = module.packages.flatMap { it.classlikes }.first()
+ val property = classLike.properties.singleOrNull { it.name == "property" }
+ assertNotNull(property)
+ assertEquals(
+ emptyList(),
+ classLike.functions
+ .filter{ it.name.contains("property", ignoreCase = true) }
+ .map { it.name }
+ )
+ assertNull(property.getter)
+ assertNull(property.setter)
+ }
+ }
+ }
+
+
+ @Test
+ fun `object jvmfield property should be static`(){
+ testInline(
+ """
+ |/src/main/kotlin/kotlinAsJavaPlugin/sample.kt
+ |package kotlinAsJavaPlugin
+ |object MyObject {
+ | @JvmField
+ | val property: String = TODO()
+ |}
+ """.trimMargin(),
+ configuration,
+ ) {
+ documentablesTransformationStage = { module ->
+ val classLike = module.packages.flatMap { it.classlikes }.first()
+ val property = classLike.properties.singleOrNull { it.name == "property" }
+ assertNotNull(property)
+
+ val extra = property.extra[AdditionalModifiers]
+ assertNotNull(extra, "Additional modifiers for property are exist")
+ assertTrue(extra.content.values.contains(setOf(ExtraModifiers.JavaOnlyModifiers.Static)),
+ "Extra modifiers contains static")
+ }
+ }
+ }
}