Skip to content

Commit

Permalink
Add more tests for expect Composables (#3851)
Browse files Browse the repository at this point in the history
  • Loading branch information
eymar authored Oct 23, 2023
1 parent ae07ddf commit d777238
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 45 deletions.
12 changes: 7 additions & 5 deletions compose/integrations/composable-test-cases/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
org.gradle.jvmargs=-Xmx2048M -XX:MaxMetaspaceSize=512m
kotlin.code.style=official
kotlin.native.enableDependencyPropagation=false
android.useAndroidX=true
kotlin.version=1.9.10
kotlin.version=1.9.20-RC
agp.version=7.3.0
compose.version=1.5.1
compose.version=1.5.10-rc01

#empty by default - a default version will be used
compose.kotlinCompilerPluginVersion=1.5.2
compose.kotlinCompilerPluginVersion=1.5.2.1-rc01

# default|failingJs - see enum class CasesToRun
tests.casesToRun=default
# comma separated names of test cases known to fail (either compilation or while running) with k/js.
tests.failing.kjs=rememberAnonymousObj
#tests.failing.kjs=rememberAnonymousObj

# TODO: we should test with both K2 and K1
#kotlin.experimental.tryK2=true
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ val casesToRun = CasesToRun.values().firstOrNull {
} ?: CasesToRun.Default


val listOfFailingJsCases = (extra["tests.failing.kjs"] as String).split(",")
val listOfFailingJsCases = (extra.properties.getOrDefault("tests.failing.kjs", "") as String).split(",")
val failingJsSuffix = "failingJs"

fun getFailingSuffix(testCaseName: String): String? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,14 @@ val Abc.commonIntVal: Int
@Composable get() = 1000

expect val Abc.composableIntVal: Int
@Composable get
@Composable get

@Composable
fun GetIntVal(): Int {
return Abc().composableIntVal
}

@Composable
fun GetIntValWithDefault(def: Int = Abc().composableIntVal): Int {
return def
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,26 @@ class Tests {
assertEquals("root:{100}", root.dump())
}

@Test
fun composableImplicitExpectActualValGetter() = runTest {
val root = composeText {
val v = GetIntVal()
TextLeafNode("$v")
}

assertEquals("root:{100}", root.dump())
}

@Test
fun composableImplicitExpectActualValGetterWithDefault() = runTest {
val root = composeText {
val v = GetIntValWithDefault()
TextLeafNode("$v")
}

assertEquals("root:{100}", root.dump())
}

@Test
fun commonComposableValGetter() = runTest {
val root = composeText {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,8 @@ plugins {
id("org.jetbrains.compose")
}

@OptIn(org.jetbrains.kotlin.gradle.kpm.external.ExternalVariantApi::class)
fun org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension.configureDefaultTargets() {
jvm("desktop")
ios()
iosArm64()
iosSimulatorArm64()
iosX64()
macosX64()
macosArm64()
// We use linux agents on CI. So it doesn't run the tests, but it builds the klib anyway which is time consuming.
if (project.isInIdea) mingwX64()
linuxX64()
}

kotlin {
if (project.isFailingJsCase) {
configureJsTargets()
} else {
configureDefaultTargets()
}
configureTargets()

sourceSets {
val commonMain by getting {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,8 @@ plugins {
id("org.jetbrains.compose")
}

@OptIn(org.jetbrains.kotlin.gradle.kpm.external.ExternalVariantApi::class)
fun org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension.configureDefaultTargets() {
jvm("desktop")
ios()
iosArm64()
iosSimulatorArm64()
iosX64()
macosX64()
macosArm64()
// We use linux agents on CI. So it doesn't run the tests, but it builds the klib anyway which is time consuming.
if (project.isInIdea) mingwX64()
linuxX64()
}

kotlin {
if (project.isFailingJsCase) {
configureJsTargets()
} else {
configureDefaultTargets()
}
configureTargets()

sourceSets {
val commonMain by getting {
Expand Down

0 comments on commit d777238

Please sign in to comment.