aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin/expectActuals
diff options
context:
space:
mode:
authorAndrzej Ratajczak <andrzej.ratajczak98@gmail.com>2020-06-25 14:22:51 +0200
committerAndrzej Ratajczak <32793002+BarkingBad@users.noreply.github.com>2020-09-08 12:52:59 +0200
commita1f8efc30b4421ce371b02b747bbeac24fafd7ba (patch)
tree7dba1baab9ad4d8db7436e65c7e9c26618a07c89 /plugins/base/src/test/kotlin/expectActuals
parent270ff58ea44b7700be45062f75bbc7fd50d183eb (diff)
downloaddokka-a1f8efc30b4421ce371b02b747bbeac24fafd7ba.tar.gz
dokka-a1f8efc30b4421ce371b02b747bbeac24fafd7ba.tar.bz2
dokka-a1f8efc30b4421ce371b02b747bbeac24fafd7ba.zip
Changed way of merging documentables to avoid exception on merging documentables of different types. Minor javadoc fixes. Changed constructor names. Add handling same name pages clash for different platforms
Diffstat (limited to 'plugins/base/src/test/kotlin/expectActuals')
-rw-r--r--plugins/base/src/test/kotlin/expectActuals/ExpectActualsTest.kt131
1 files changed, 131 insertions, 0 deletions
diff --git a/plugins/base/src/test/kotlin/expectActuals/ExpectActualsTest.kt b/plugins/base/src/test/kotlin/expectActuals/ExpectActualsTest.kt
new file mode 100644
index 00000000..090196b3
--- /dev/null
+++ b/plugins/base/src/test/kotlin/expectActuals/ExpectActualsTest.kt
@@ -0,0 +1,131 @@
+package expectActuals
+
+import org.jetbrains.dokka.pages.ClasslikePageNode
+import org.jetbrains.dokka.pages.PageNode
+import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest
+import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.Assertions.assertTrue
+
+
+class ExpectActualsTest : AbstractCoreTest() {
+
+ fun PageNode.childrenRec(): List<PageNode> = listOf(this) + children.flatMap { it.childrenRec() }
+
+ @Test
+ fun `two same named expect actual classes`() {
+
+ val configuration = dokkaConfiguration {
+ sourceSets {
+ val common = sourceSet {
+ moduleName = "example"
+ name = "common"
+ displayName = "common"
+ analysisPlatform = "common"
+ sourceRoots = listOf("src/commonMain/kotlin/pageMerger/Test.kt")
+ }
+ val commonJ = sourceSet {
+ moduleName = "example"
+ name = "commonJ"
+ displayName = "commonJ"
+ analysisPlatform = "common"
+ sourceRoots = listOf("src/commonJMain/kotlin/pageMerger/Test.kt")
+ dependentSourceSets = setOf(common.sourceSetID)
+ }
+ val commonN = sourceSet {
+ moduleName = "example"
+ name = "commonN"
+ displayName = "commonN"
+ analysisPlatform = "common"
+ sourceRoots = listOf("src/commonNMain/kotlin/pageMerger/Test.kt")
+ dependentSourceSets = setOf(common.sourceSetID)
+ }
+ val js = sourceSet {
+ moduleName = "example"
+ name = "js"
+ displayName = "js"
+ analysisPlatform = "js"
+ dependentSourceSets = setOf(commonJ.sourceSetID)
+ sourceRoots = listOf("src/jsMain/kotlin/pageMerger/Test.kt")
+ }
+ val jvm = sourceSet {
+ moduleName = "example"
+ name = "jvm"
+ displayName = "jvm"
+ analysisPlatform = "jvm"
+ dependentSourceSets = setOf(commonJ.sourceSetID)
+ sourceRoots = listOf("src/jvmMain/kotlin/pageMerger/Test.kt")
+ }
+ val linuxX64 = sourceSet {
+ moduleName = "example"
+ name = "linuxX64"
+ displayName = "linuxX64"
+ analysisPlatform = "native"
+ dependentSourceSets = setOf(commonN.sourceSetID)
+ sourceRoots = listOf("src/linuxX64Main/kotlin/pageMerger/Test.kt")
+ }
+ val mingwX64 = sourceSet {
+ moduleName = "example"
+ name = "mingwX64"
+ displayName = "mingwX64"
+ analysisPlatform = "native"
+ dependentSourceSets = setOf(commonN.sourceSetID)
+ sourceRoots = listOf("src/mingwX64Main/kotlin/pageMerger/Test.kt")
+ }
+ }
+ }
+
+ testInline(
+ """
+ |/src/commonMain/kotlin/pageMerger/Test.kt
+ |package pageMerger
+ |
+ |/src/commonJMain/kotlin/pageMerger/Test.kt
+ |package pageMerger
+ |
+ |expect class A
+ |
+ |/src/commonNMain/kotlin/pageMerger/Test.kt
+ |package pageMerger
+ |
+ |expect class A
+ |
+ |/src/jsMain/kotlin/pageMerger/Test.kt
+ |package pageMerger
+ |
+ |actual class A
+ |
+ |/src/jvmMain/kotlin/pageMerger/Test.kt
+ |package pageMerger
+ |
+ |actual class A
+ |
+ |/src/linuxX64/kotlin/pageMerger/Test.kt
+ |package pageMerger
+ |
+ |actual class A
+ |
+ |/src/mingwX64Main/kotlin/pageMerger/Test.kt
+ |package pageMerger
+ |
+ |actual class A
+ |
+ """.trimMargin(),
+ configuration
+ ) {
+ pagesTransformationStage = {
+ println(it)
+ val allChildren = it.childrenRec().filterIsInstance<ClasslikePageNode>()
+ val jvmClass = allChildren.filter { it.name == "DoNotMerge(jvm)" }
+ val jsClass = allChildren.filter { it.name == "DoNotMerge(js)" }
+ val noClass = allChildren.filter { it.name == "DoNotMerge" }
+ assertTrue(jvmClass.size == 1) { "There can be only one DoNotMerge(jvm) page" }
+ assertTrue(jvmClass.first().documentable?.sourceSets?.single()?.analysisPlatform?.key == "jvm") { "DoNotMerge(jvm) should have only jvm sources" }
+
+ assertTrue(jsClass.size == 1) { "There can be only one DoNotMerge(js) page" }
+ assertTrue(jsClass.first().documentable?.sourceSets?.single()?.analysisPlatform?.key == "js") { "DoNotMerge(js) should have only js sources" }
+
+ assertTrue(noClass.isEmpty()) { "There can't be any DoNotMerge page" }
+ }
+ }
+ }
+} \ No newline at end of file