aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin/model/ObjectTest.kt
blob: 009b406e875cf36324ba115bfa2a28413258228b (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
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
 * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
 */

package model

import org.jetbrains.dokka.model.AdditionalModifiers
import org.jetbrains.dokka.model.DObject
import org.jetbrains.dokka.model.ExtraModifiers
import utils.AbstractModelTest
import kotlin.test.Test

class ObjectTest : AbstractModelTest("/src/main/kotlin/objects/Test.kt", "objects") {

    @Test
    fun emptyObject() {
        inlineModelTest(
            """
            |object Obj {}
            """.trimIndent()
        ) {
            with((this / "objects" / "Obj").cast<DObject>()) {
                name equals "Obj"
                children counts 3
            }
        }
    }

    @Test
    fun `data object class`() {
        inlineModelTest(
            """
            |data object KotlinDataObject {}
            """.trimIndent()
        ) {
            with((this / "objects" / "KotlinDataObject").cast<DObject>()) {
                name equals "KotlinDataObject"
                extra[AdditionalModifiers]?.content?.values?.single()
                    ?.single() equals ExtraModifiers.KotlinOnlyModifiers.Data
            }
        }
    }
}