From 4ebd80f03e33791f6805b59b98d2f5a535c7847e Mon Sep 17 00:00:00 2001 From: "Oleksandr.Karpovich" Date: Tue, 21 Jan 2025 17:20:58 +0100 Subject: [PATCH] Fix the tests after updating to Kotlin 2.1.0 --- .../org/jetbrains/compose/resources/ComposeResourceTest.kt | 3 +++ .../org/jetbrains/compose/resources/RecompositionsCounter.kt | 2 ++ .../org/jetbrains/compose/resources/StringFormatTest.kt | 2 +- html/core/src/jsTest/kotlin/FailingTestCases.kt | 4 +++- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/components/resources/library/src/commonTest/kotlin/org/jetbrains/compose/resources/ComposeResourceTest.kt b/components/resources/library/src/commonTest/kotlin/org/jetbrains/compose/resources/ComposeResourceTest.kt index 0cc4b8651a7..339275a106d 100644 --- a/components/resources/library/src/commonTest/kotlin/org/jetbrains/compose/resources/ComposeResourceTest.kt +++ b/components/resources/library/src/commonTest/kotlin/org/jetbrains/compose/resources/ComposeResourceTest.kt @@ -5,7 +5,10 @@ import androidx.compose.material3.Text import androidx.compose.runtime.* import androidx.compose.ui.test.ExperimentalTestApi import androidx.compose.ui.test.runComposeUiTest +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.delay import kotlinx.coroutines.test.runTest +import kotlinx.coroutines.withContext import kotlin.test.* @OptIn(ExperimentalTestApi::class, InternalResourceApi::class) diff --git a/components/resources/library/src/commonTest/kotlin/org/jetbrains/compose/resources/RecompositionsCounter.kt b/components/resources/library/src/commonTest/kotlin/org/jetbrains/compose/resources/RecompositionsCounter.kt index 8c2501b6e4f..97866c3d483 100644 --- a/components/resources/library/src/commonTest/kotlin/org/jetbrains/compose/resources/RecompositionsCounter.kt +++ b/components/resources/library/src/commonTest/kotlin/org/jetbrains/compose/resources/RecompositionsCounter.kt @@ -1,12 +1,14 @@ package org.jetbrains.compose.resources import androidx.compose.runtime.Composable +import androidx.compose.runtime.NonSkippableComposable internal class RecompositionsCounter { var count = 0 private set @Composable + @NonSkippableComposable fun content(block: @Composable () -> Unit) { count++ block() diff --git a/components/resources/library/src/commonTest/kotlin/org/jetbrains/compose/resources/StringFormatTest.kt b/components/resources/library/src/commonTest/kotlin/org/jetbrains/compose/resources/StringFormatTest.kt index 75765ac4cae..4ebdfb33664 100644 --- a/components/resources/library/src/commonTest/kotlin/org/jetbrains/compose/resources/StringFormatTest.kt +++ b/components/resources/library/src/commonTest/kotlin/org/jetbrains/compose/resources/StringFormatTest.kt @@ -87,7 +87,7 @@ class StringFormatTest { } @Test - fun `replaceWithArgs ensures %d and %s placeholders behave identically`() { + fun `replaceWithArgs ensures _d and _s placeholders behave identically`() { val template = "%1\$d, %1\$s, %2\$d, %2\$s" val args = listOf("42", "hello") diff --git a/html/core/src/jsTest/kotlin/FailingTestCases.kt b/html/core/src/jsTest/kotlin/FailingTestCases.kt index 549da12b156..9e4f0d00e4c 100644 --- a/html/core/src/jsTest/kotlin/FailingTestCases.kt +++ b/html/core/src/jsTest/kotlin/FailingTestCases.kt @@ -6,6 +6,7 @@ package org.jetbrains.compose.web.core.tests import kotlin.test.Test +import kotlin.test.assertFalse import kotlin.test.assertTrue class FailingTestCases { @@ -20,7 +21,8 @@ class FailingTestCases { } catch (e: Throwable) { expectedErrorThrown = true } - assertTrue(expectedErrorThrown) + // No exception in Kotlin 2.1.0 + assertFalse(expectedErrorThrown) } }