Browse Source

add a test for composable getter in expect/actual val getter (#3456)

pull/2846/merge
Oleksandr Karpovich 1 year ago committed by GitHub
parent
commit
1d6752b912
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      compose/integrations/composable-test-cases/gradle.properties
  2. 3
      compose/integrations/composable-test-cases/settings.gradle.kts
  3. 39
      compose/integrations/composable-test-cases/testcases/expectActual/lib/build.gradle.kts
  4. 10
      compose/integrations/composable-test-cases/testcases/expectActual/lib/src/commonMain/kotlin/Dependencies.kt
  5. 4
      compose/integrations/composable-test-cases/testcases/expectActual/lib/src/desktopMain/kotlin/Actuals.kt
  6. 4
      compose/integrations/composable-test-cases/testcases/expectActual/lib/src/jsMain/kotlin/Actuals.kt
  7. 4
      compose/integrations/composable-test-cases/testcases/expectActual/lib/src/nativeMain/kotlin/Actuals.kt
  8. 21
      compose/integrations/composable-test-cases/testcases/expectActual/main/build.gradle.kts
  9. 32
      compose/integrations/composable-test-cases/testcases/expectActual/main/src/commonTest/kotlin/Tests.kt

6
compose/integrations/composable-test-cases/gradle.properties

@ -2,13 +2,13 @@ org.gradle.jvmargs=-Xmx2048M -XX:MaxMetaspaceSize=512m
kotlin.code.style=official
kotlin.native.enableDependencyPropagation=false
android.useAndroidX=true
kotlin.version=1.8.20
kotlin.version=1.9.0
agp.version=7.3.0
compose.version=1.5.0-dev1063
compose.version=1.5.0-beta01
kotlin.native.cacheKind=none
#empty by default - a default version will be used
compose.kotlinCompilerPluginVersion=1.4.2
compose.kotlinCompilerPluginVersion=1.5.0
# default|failingJs - see enum class CasesToRun
tests.casesToRun=default

3
compose/integrations/composable-test-cases/settings.gradle.kts

@ -118,6 +118,9 @@ if (casesToRun.isDefault()) {
module(":testcase-lambdas-lib", "testcases/lambdas/lib")
module(":testcase-lambdas-main", "testcases/lambdas/main")
module(":testcase-expectActual-lib", "testcases/expectActual/lib")
module(":testcase-expectActual-main", "testcases/expectActual/main")
}
/**

39
compose/integrations/composable-test-cases/testcases/expectActual/lib/build.gradle.kts

@ -0,0 +1,39 @@
plugins {
kotlin("multiplatform")
id("org.jetbrains.compose")
}
kotlin {
configureTargets()
sourceSets {
val commonMain by getting {
dependencies {
implementation(compose.runtime)
implementation(getCommonLib())
}
}
val commonTest by getting {
configureCommonTestDependencies()
}
val nativeMain by creating {
dependsOn(commonMain)
}
val iosMain by getting {
dependsOn(nativeMain)
}
val linuxX64Main by getting {
dependsOn(nativeMain)
}
val macosX64Main by getting {
dependsOn(nativeMain)
}
val macosArm64Main by getting {
dependsOn(nativeMain)
}
val mingwX64Main by getting {
dependsOn(nativeMain)
}
}
}

10
compose/integrations/composable-test-cases/testcases/expectActual/lib/src/commonMain/kotlin/Dependencies.kt

@ -0,0 +1,10 @@
import androidx.compose.runtime.Composable
class Abc
val Abc.commonIntVal: Int
@Composable get() = 1000
expect val Abc.composableIntVal: Int
@Composable get

4
compose/integrations/composable-test-cases/testcases/expectActual/lib/src/desktopMain/kotlin/Actuals.kt

@ -0,0 +1,4 @@
import androidx.compose.runtime.Composable
actual val Abc.composableIntVal: Int
@Composable get () = 100

4
compose/integrations/composable-test-cases/testcases/expectActual/lib/src/jsMain/kotlin/Actuals.kt

@ -0,0 +1,4 @@
import androidx.compose.runtime.Composable
actual val Abc.composableIntVal: Int
@Composable get () = 100

4
compose/integrations/composable-test-cases/testcases/expectActual/lib/src/nativeMain/kotlin/Actuals.kt

@ -0,0 +1,4 @@
import androidx.compose.runtime.Composable
actual val Abc.composableIntVal: Int
@Composable get () = 100

21
compose/integrations/composable-test-cases/testcases/expectActual/main/build.gradle.kts

@ -0,0 +1,21 @@
plugins {
kotlin("multiplatform")
id("org.jetbrains.compose")
}
kotlin {
configureTargets()
sourceSets {
val commonMain by getting {
dependencies {
implementation(compose.runtime)
implementation(getCommonLib())
implementation(getLibDependencyForMain())
}
}
val commonTest by getting {
configureCommonTestDependencies()
}
}
}

32
compose/integrations/composable-test-cases/testcases/expectActual/main/src/commonTest/kotlin/Tests.kt

@ -0,0 +1,32 @@
import com.example.common.TextLeafNode
import com.example.common.composeText
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import kotlin.test.Test
import kotlin.test.assertEquals
@OptIn(ExperimentalCoroutinesApi::class)
class Tests {
@Test
// K/JS fails. Related: https://github.com/JetBrains/compose-multiplatform/issues/3373
fun composableExpectActualValGetter() = runTest {
val root = composeText {
val v = Abc().composableIntVal
TextLeafNode("$v")
}
assertEquals("root:{100}", root.dump())
}
@Test
fun commonComposableValGetter() = runTest {
val root = composeText {
val v = Abc().commonIntVal
TextLeafNode("$v")
}
assertEquals("root:{1000}", root.dump())
}
}
Loading…
Cancel
Save