aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test
diff options
context:
space:
mode:
authorMarcin Aman <marcin.aman@gmail.com>2021-04-14 15:16:27 +0200
committerGitHub <noreply@github.com>2021-04-14 15:16:27 +0200
commitacd9234be6909a69f89600e9c8ddde642d36b1cf (patch)
tree5494b5c6dbcd74c2cee408659fbcfef6d47def7d /plugins/base/src/test
parent357ee8a2836d96204343ff20cab8d17ad2f09aed (diff)
downloaddokka-acd9234be6909a69f89600e9c8ddde642d36b1cf.tar.gz
dokka-acd9234be6909a69f89600e9c8ddde642d36b1cf.tar.bz2
dokka-acd9234be6909a69f89600e9c8ddde642d36b1cf.zip
Fix visibility on enum entry property (#1828)
Diffstat (limited to 'plugins/base/src/test')
-rw-r--r--plugins/base/src/test/kotlin/enums/EnumsTest.kt2
-rw-r--r--plugins/base/src/test/kotlin/filter/VisibilityFilterTest.kt81
2 files changed, 82 insertions, 1 deletions
diff --git a/plugins/base/src/test/kotlin/enums/EnumsTest.kt b/plugins/base/src/test/kotlin/enums/EnumsTest.kt
index eb35085e..2535140c 100644
--- a/plugins/base/src/test/kotlin/enums/EnumsTest.kt
+++ b/plugins/base/src/test/kotlin/enums/EnumsTest.kt
@@ -115,7 +115,7 @@ class EnumsTest : BaseAbstractTest() {
m.packages.let { p ->
p.first().classlikes.let { c ->
val enum = c.first() as DEnum
- val (first, second) = enum.entries
+ val (first, second) = enum.entries.sortedBy { it.name }
assertEquals(1, first.extra.allOfType<ConstructorValues>().size)
assertEquals(1, second.extra.allOfType<ConstructorValues>().size)
diff --git a/plugins/base/src/test/kotlin/filter/VisibilityFilterTest.kt b/plugins/base/src/test/kotlin/filter/VisibilityFilterTest.kt
index 416db52b..ffefaaea 100644
--- a/plugins/base/src/test/kotlin/filter/VisibilityFilterTest.kt
+++ b/plugins/base/src/test/kotlin/filter/VisibilityFilterTest.kt
@@ -2,9 +2,12 @@ package filter
import org.jetbrains.dokka.PackageOptionsImpl
import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
+import org.jetbrains.dokka.model.DEnum
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import kotlin.test.assertEquals
+import kotlin.test.assertFalse
+import kotlin.test.assertTrue
class VisibilityFilterTest : BaseAbstractTest() {
@@ -206,4 +209,82 @@ class VisibilityFilterTest : BaseAbstractTest() {
}
}
}
+
+ @Test
+ fun `internal property from enum should be skipped`() {
+ val configuration = dokkaConfiguration {
+ sourceSets {
+ sourceSet {
+ includeNonPublic = false
+ sourceRoots = listOf("src/main/kotlin/basic/Test.kt")
+ }
+ }
+ }
+ testInline(
+ """
+ |/src/main/kotlin/basic/Test.kt
+ |package enums
+ |
+ |enum class Test(internal val value: Int) {
+ | A(0) {
+ | override fun testFun(): Float = 0.05F
+ | },
+ | B(1) {
+ | override fun testFun(): Float = 0.1F
+ | };
+ |
+ | internal open fun testFun(): Float = 0.5F
+ |}
+ """.trimMargin(),
+ configuration
+ ) {
+ documentablesTransformationStage = { module ->
+ val enum = module.packages.flatMap { it.classlikes }.filterIsInstance<DEnum>().first()
+ val entry = enum.entries.first()
+
+ assertFalse("testFun" in entry.functions.map { it.name })
+ assertFalse("value" in entry.properties.map { it.name })
+ assertFalse("testFun" in enum.functions.map { it.name })
+ }
+ }
+ }
+
+ @Test
+ fun `internal property from enum`() {
+ val configuration = dokkaConfiguration {
+ sourceSets {
+ sourceSet {
+ includeNonPublic = true
+ sourceRoots = listOf("src/main/kotlin/basic/Test.kt")
+ }
+ }
+ }
+ testInline(
+ """
+ |/src/main/kotlin/basic/Test.kt
+ |package enums
+ |
+ |enum class Test(internal val value: Int) {
+ | A(0) {
+ | override fun testFun(): Float = 0.05F
+ | },
+ | B(1) {
+ | override fun testFun(): Float = 0.1F
+ | };
+ |
+ | internal open fun testFun(): Float = 0.5F
+ |}
+ """.trimMargin(),
+ configuration
+ ) {
+ documentablesTransformationStage = { module ->
+ val enum = module.packages.flatMap { it.classlikes }.filterIsInstance<DEnum>().first()
+ val entry = enum.entries.first()
+
+ assertTrue("testFun" in entry.functions.map { it.name })
+ assertTrue("value" in entry.properties.map { it.name })
+ assertTrue("testFun" in enum.functions.map { it.name })
+ }
+ }
+ }
}