Skip to content

Commit

Permalink
update tests to be clear
Browse files Browse the repository at this point in the history
  • Loading branch information
whyoleg committed May 21, 2024
1 parent a0f5fb7 commit 8e62204
Showing 1 changed file with 45 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import org.jetbrains.dokka.model.withDescendants
import org.jetbrains.dokka.pages.ClasslikePageNode
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
import kotlin.test.assertTrue


Expand Down Expand Up @@ -43,7 +42,7 @@ class ExpectActualsTest : BaseAbstractTest() {
multiplatformConfiguration.sourceSets.single { it.displayName == "common" }.sourceSetID

@Test
fun `should recognize expect property in class`() = testInline(
fun `property inside expect class should be marked as expect`() = testInline(
"""
/src/common/test.kt
expect class ExpectActualClass {
Expand Down Expand Up @@ -73,7 +72,7 @@ class ExpectActualsTest : BaseAbstractTest() {
}

@Test
fun `should recognize expect function in class`() = testInline(
fun `function inside expect class should be marked as expect`() = testInline(
"""
/src/common/test.kt
expect class ExpectActualClass {
Expand All @@ -96,12 +95,54 @@ class ExpectActualsTest : BaseAbstractTest() {
val cls = module.packages.single().classlikes.single { it.name == "ExpectActualClass" }
assertTrue(cls.isExpectActual)
assertEquals(commonSourceSetId, cls.expectPresentInSet?.sourceSetID)
val property = cls.functions.single { it.name == "function" }
val function = cls.functions.single { it.name == "function" }
assertTrue(function.isExpectActual)
assertEquals(commonSourceSetId, function.expectPresentInSet?.sourceSetID)
}
}

@Test
fun `top level expect property should be marked as expect`() = testInline(
"""
/src/common/test.kt
expect val property: String?
/src/jvm/test.kt
actual val property: String? = null
/src/native/test.kt
actual val property: String? = null
""".trimMargin(),
multiplatformConfiguration
) {
documentablesTransformationStage = { module ->
val property = module.packages.single().properties.single { it.name == "property" }
assertTrue(property.isExpectActual)
assertEquals(commonSourceSetId, property.expectPresentInSet?.sourceSetID)
}
}

@Test
fun `top level expect function should be marked as expect`() = testInline(
"""
/src/common/test.kt
expect fun function(): String?
/src/jvm/test.kt
actual fun function(): String? = null
/src/native/test.kt
actual fun function(): String? = null
""".trimMargin(),
multiplatformConfiguration
) {
documentablesTransformationStage = { module ->
val function = module.packages.single().functions.single { it.name == "function" }
assertTrue(function.isExpectActual)
assertEquals(commonSourceSetId, function.expectPresentInSet?.sourceSetID)
}
}

@Test
fun `three same named expect actual classes`() {

Expand Down

0 comments on commit 8e62204

Please sign in to comment.