aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin/model/annotations/KotlinAnnotationsForParametersTest.kt
blob: 4cc34c095fec01e53b0c49f8df3c85ab2f74aec1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package model.annotations

import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.Annotations
import org.jetbrains.dokka.model.DFunction
import org.junit.jupiter.api.Test
import utils.AbstractModelTest
import kotlin.test.assertEquals

class KotlinAnnotationsForParametersTest : AbstractModelTest("/src/main/kotlin/annotations/Test.kt", "annotations") {
    @Test
    fun `generic receiver with annotations`() {
        inlineModelTest(
            """
             |@Target(AnnotationTarget.TYPE_PARAMETER)
             |annotation class Hello(val bar: String)
             |fun <@Hello("abc") T> foo(arg: String): List<T> = TODO()
            """.trimIndent()
        ) {
            with((this / "annotations" / "foo").cast<DFunction>()) {
                val annotations = generics.first().extra[Annotations]?.directAnnotations?.flatMap { it.value }
                val driOfHello = DRI("annotations", "Hello")
                val annotationsValues = annotations?.flatMap { it.params.values }?.map { it.toString() }?.toList()

                assertEquals(listOf(driOfHello), annotations?.map { it.dri })
                assertEquals(listOf("abc"), annotationsValues)
            }
        }
    }
}