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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
package org.jetbrains.dokka.tests
import org.jetbrains.dokka.*
import org.junit.Assert
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
abstract class BasePropertyTest(val analysisPlatform: Platform) {
protected val defaultModelConfig = ModelConfig(analysisPlatform = analysisPlatform)
@Test fun valueProperty() {
checkSourceExistsAndVerifyModel("testdata/properties/valueProperty.kt", defaultModelConfig) { model ->
with(model.members.single().members.single()) {
assertEquals("property", name)
assertEquals(NodeKind.Property, kind)
assertEquals(Content.Empty, content)
assertEquals("String", detail(NodeKind.Type).name)
assertTrue(members.none())
assertTrue(links.none())
}
}
}
@Test fun variableProperty() {
checkSourceExistsAndVerifyModel("testdata/properties/variableProperty.kt", defaultModelConfig) { model ->
with(model.members.single().members.single()) {
assertEquals("property", name)
assertEquals(NodeKind.Property, kind)
assertEquals(Content.Empty, content)
assertEquals("String", detail(NodeKind.Type).name)
assertTrue(members.none())
assertTrue(links.none())
}
}
}
@Test fun valuePropertyWithGetter() {
checkSourceExistsAndVerifyModel("testdata/properties/valuePropertyWithGetter.kt", defaultModelConfig) { model ->
with(model.members.single().members.single()) {
assertEquals("property", name)
assertEquals(NodeKind.Property, kind)
assertEquals(Content.Empty, content)
assertEquals("String", detail(NodeKind.Type).name)
assertTrue(links.none())
assertTrue(members.none())
}
}
}
@Test fun variablePropertyWithAccessors() {
checkSourceExistsAndVerifyModel("testdata/properties/variablePropertyWithAccessors.kt", defaultModelConfig) { model ->
with(model.members.single().members.single()) {
assertEquals("property", name)
assertEquals(NodeKind.Property, kind)
assertEquals(Content.Empty, content)
assertEquals("String", detail(NodeKind.Type).name)
val modifiers = details(NodeKind.Modifier).map { it.name }
assertTrue("final" in modifiers)
assertTrue("public" in modifiers)
assertTrue("var" in modifiers)
assertTrue(links.none())
assertTrue(members.none())
}
}
}
@Test fun propertyWithReceiver() {
checkSourceExistsAndVerifyModel(
"testdata/properties/propertyWithReceiver.kt",
defaultModelConfig
) { model ->
with(model.members.single().members.single()) {
assertEquals("kotlin.String", name)
assertEquals(NodeKind.ExternalClass, kind)
with(members.single()) {
assertEquals("foobar", name)
assertEquals(NodeKind.Property, kind)
}
}
}
}
@Test fun propertyOverride() {
checkSourceExistsAndVerifyModel("testdata/properties/propertyOverride.kt", defaultModelConfig) { model ->
with(model.members.single().members.single { it.name == "Bar" }.members.single { it.name == "xyzzy"}) {
assertEquals("xyzzy", name)
val override = references(RefKind.Override).single().to
assertEquals("xyzzy", override.name)
assertEquals("Foo", override.owner!!.name)
}
}
}
@Test fun sinceKotlin() {
checkSourceExistsAndVerifyModel("testdata/properties/sinceKotlin.kt", defaultModelConfig) { model ->
with(model.members.single().members.single()) {
assertEquals(listOf("Kotlin 1.1"), platforms)
}
}
}
}
class JSPropertyTest: BasePropertyTest(Platform.js) {}
class JVMPropertyTest : BasePropertyTest(Platform.jvm) {
@Test
fun annotatedProperty() {
checkSourceExistsAndVerifyModel(
"testdata/properties/annotatedProperty.kt",
modelConfig = ModelConfig(
analysisPlatform = analysisPlatform,
withKotlinRuntime = true
)
) { model ->
with(model.members.single().members.single()) {
Assert.assertEquals(1, annotations.count())
with(annotations[0]) {
Assert.assertEquals("Strictfp", name)
Assert.assertEquals(Content.Empty, content)
Assert.assertEquals(NodeKind.Annotation, kind)
}
}
}
}
}
class CommonPropertyTest: BasePropertyTest(Platform.common) {}
|