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
130
131
132
133
134
|
package model
import org.jetbrains.dokka.model.DPackage
import org.junit.jupiter.api.Test
import utils.AbstractModelTest
class PackagesTest : AbstractModelTest("/src/main/kotlin/packages/Test.kt", "packages") {
@Test
fun rootPackage() {
inlineModelTest(
"""
|
""".trimIndent(),
prependPackage = false,
configuration = dokkaConfiguration {
sourceSets {
sourceSet {
sourceRoots = listOf("src/main/kotlin")
displayName = "JVM"
}
}
}
) {
with((this / "[root]").cast<DPackage>()) {
packageName equals ""
children counts 0
}
}
}
@Test
fun simpleNamePackage() {
inlineModelTest(
"""
|package simple
""".trimIndent(),
prependPackage = false
) {
with((this / "simple").cast<DPackage>()) {
packageName equals "simple"
children counts 0
}
}
}
@Test
fun dottedNamePackage() {
inlineModelTest(
"""
|package dot.name
""".trimIndent(),
prependPackage = false
) {
with((this / "dot.name").cast<DPackage>()) {
packageName equals "dot.name"
children counts 0
}
}
}
@Test
fun multipleFiles() {
inlineModelTest(
"""
|package dot.name
|/src/main/kotlin/packages/Test2.kt
|package simple
""".trimIndent(),
prependPackage = false
) {
children counts 2
with((this / "dot.name").cast<DPackage>()) {
packageName equals "dot.name"
children counts 0
}
with((this / "simple").cast<DPackage>()) {
packageName equals "simple"
children counts 0
}
}
}
@Test
fun multipleFilesSamePackage() {
inlineModelTest(
"""
|package simple
|/src/main/kotlin/packages/Test2.kt
|package simple
""".trimIndent(),
prependPackage = false
) {
children counts 1
with((this / "simple").cast<DPackage>()) {
packageName equals "simple"
children counts 0
}
}
}
@Test
fun classAtPackageLevel() {
inlineModelTest(
"""
|package simple.name
|
|class Foo {}
""".trimIndent(),
prependPackage = false
) {
with((this / "simple.name").cast<DPackage>()) {
packageName equals "simple.name"
children counts 1
}
}
}
// todo
// @Test fun suppressAtPackageLevel() {
// verifyModel(
// ModelConfig(
// roots = arrayOf(KotlinSourceRoot("testdata/packages/classInPackage.kt", false)),
// perPackageOptions = listOf(
// PackageOptionsImpl(prefix = "simple.name", suppress = true)
// ),
// analysisPlatform = analysisPlatform
// )
// ) { model ->
// assertEquals(0, model.members.count())
// }
// }
}
|