aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/src/test/kotlin/signatures/SignatureTest.kt')
-rw-r--r--plugins/base/src/test/kotlin/signatures/SignatureTest.kt37
1 files changed, 37 insertions, 0 deletions
diff --git a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
index 2d17b7f8..75c199fa 100644
--- a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
+++ b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
@@ -2,8 +2,12 @@ package signatures
import org.jetbrains.dokka.DokkaSourceSetID
import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
+import org.jetbrains.dokka.model.DFunction
+import org.jetbrains.dokka.model.DefinitelyNonNullable
+import org.jetbrains.dokka.model.dfs
import org.junit.jupiter.api.Test
import utils.*
+import kotlin.test.assertEquals
import kotlin.test.assertFalse
class SignatureTest : BaseAbstractTest() {
@@ -186,6 +190,39 @@ class SignatureTest : BaseAbstractTest() {
}
@Test
+ fun `fun with definitely non-nullable types`() {
+ val source = source("fun <T> elvisLike(x: T, y: T & Any): T & Any = x ?: y")
+ val writerPlugin = TestOutputWriterPlugin()
+
+ testInline(
+ source,
+ configuration,
+ pluginOverrides = listOf(writerPlugin)
+ ) {
+ documentablesTransformationStage = {
+ val fn = (it.dfs { it.name == "elvisLike" } as? DFunction).assertNotNull("Function elvisLike")
+
+ assert(fn.type is DefinitelyNonNullable)
+ assert(fn.parameters[1].type is DefinitelyNonNullable)
+ }
+ renderingStage = { _, _ ->
+ val signature = writerPlugin.writer.renderedContent("root/example/elvis-like.html")
+ assertEquals(2, signature.select("a[href=\"https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html\"]").size)
+ signature.firstSignature().match(
+ "fun <", A("T"), "> ", A("elvisLike"),
+ "(",
+ Span(
+ Span("x: ", A("T"), ", "),
+ Span("y: ", A("T"), " & ", A("Any"))
+ ),
+ "): ", A("T"), " & ", A("Any"), Span(),
+ ignoreSpanWithTokenStyle = true
+ )
+ }
+ }
+ }
+
+ @Test
fun `fun with keywords, params and generic bound`() {
val source = source("inline suspend fun <T : String> simpleFun(a: Int, b: String): T = \"Celebrimbor\" as T")
val writerPlugin = TestOutputWriterPlugin()