From c3d5421084fd6474afe5512700bca9616fc64cdf Mon Sep 17 00:00:00 2001 From: Nicklas Jensen <800751+Nillerr@users.noreply.github.com> Date: Tue, 11 Oct 2022 10:21:07 +0200 Subject: [PATCH] Update dependencies, use concurrent memory manager and remove freezing --- gradle.properties | 1 + kontinuity-core/build.gradle.kts | 1 + .../kotlin/io/mockative/kontinuity/internal/Freeze.kt | 6 ------ .../mockative/kontinuity/internal/KontinuityCallback.kt | 2 +- .../kontinuity/internal/KontinuityCancellable.kt | 2 +- .../io/mockative/kontinuity/internal/KontinuityFlow.kt | 2 +- .../mockative/kontinuity/internal/KontinuityStateFlow.kt | 2 +- .../io/mockative/kontinuity/internal/KontinuitySuspend.kt | 2 +- .../io/mockative/kontinuity/internal/KontinuityError.kt | 2 +- .../kotlin/io/mockative/kontinuity/internal/Freeze.kt | 3 --- .../kotlin/io/mockative/kontinuity/internal/Freeze.kt | 3 --- .../kotlin/io/mockative/kontinuity/internal/Freeze.kt | 5 ----- shared/build.gradle.kts | 8 ++++---- .../kotlin/com/app/sample/AuthenticationServiceTests.kt | 3 ++- 14 files changed, 14 insertions(+), 28 deletions(-) delete mode 100644 kontinuity-core/src/commonMain/kotlin/io/mockative/kontinuity/internal/Freeze.kt delete mode 100644 kontinuity-core/src/jsMain/kotlin/io/mockative/kontinuity/internal/Freeze.kt delete mode 100644 kontinuity-core/src/jvmMain/kotlin/io/mockative/kontinuity/internal/Freeze.kt delete mode 100644 kontinuity-core/src/nativeMain/kotlin/io/mockative/kontinuity/internal/Freeze.kt diff --git a/gradle.properties b/gradle.properties index f95437e..3a7d2d6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,6 +7,7 @@ kotlin.mpp.stability.nowarn=true #kotlin.mpp.enableGranularSourceSetsMetadata=true kotlin.mpp.enableCompatibilityMetadataVariant=true #kotlin.native.enableDependencyPropagation=false +kotlin.native.binary.memoryModel=experimental #Android android.useAndroidX=true diff --git a/kontinuity-core/build.gradle.kts b/kontinuity-core/build.gradle.kts index 6be17e5..774204b 100644 --- a/kontinuity-core/build.gradle.kts +++ b/kontinuity-core/build.gradle.kts @@ -12,6 +12,7 @@ kotlin { val commonMain by getting { dependencies { implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4") + implementation("org.jetbrains.kotlinx:atomicfu:0.18.4") } } diff --git a/kontinuity-core/src/commonMain/kotlin/io/mockative/kontinuity/internal/Freeze.kt b/kontinuity-core/src/commonMain/kotlin/io/mockative/kontinuity/internal/Freeze.kt deleted file mode 100644 index f659af0..0000000 --- a/kontinuity-core/src/commonMain/kotlin/io/mockative/kontinuity/internal/Freeze.kt +++ /dev/null @@ -1,6 +0,0 @@ -package io.mockative.kontinuity.internal - -/** - * Freezes this object in Kotlin/Native. - */ -internal expect fun T.freeze(): T diff --git a/kontinuity-core/src/commonMain/kotlin/io/mockative/kontinuity/internal/KontinuityCallback.kt b/kontinuity-core/src/commonMain/kotlin/io/mockative/kontinuity/internal/KontinuityCallback.kt index 9bea8c7..09ca2ad 100644 --- a/kontinuity-core/src/commonMain/kotlin/io/mockative/kontinuity/internal/KontinuityCallback.kt +++ b/kontinuity-core/src/commonMain/kotlin/io/mockative/kontinuity/internal/KontinuityCallback.kt @@ -3,4 +3,4 @@ package io.mockative.kontinuity.internal typealias KontinuityCallback = (T, Unit) -> Unit @Suppress("NOTHING_TO_INLINE") -internal inline operator fun KontinuityCallback.invoke(value: T) = invoke(value.freeze(), Unit) \ No newline at end of file +internal inline operator fun KontinuityCallback.invoke(value: T) = invoke(value, Unit) \ No newline at end of file diff --git a/kontinuity-core/src/commonMain/kotlin/io/mockative/kontinuity/internal/KontinuityCancellable.kt b/kontinuity-core/src/commonMain/kotlin/io/mockative/kontinuity/internal/KontinuityCancellable.kt index 7c690c2..3545d17 100644 --- a/kontinuity-core/src/commonMain/kotlin/io/mockative/kontinuity/internal/KontinuityCancellable.kt +++ b/kontinuity-core/src/commonMain/kotlin/io/mockative/kontinuity/internal/KontinuityCancellable.kt @@ -5,4 +5,4 @@ import kotlinx.coroutines.Job typealias KontinuityCancellable = () -> Unit @Suppress("NOTHING_TO_INLINE") -internal inline fun Job.asNativeCancellable(): KontinuityCancellable = { cancel() }.freeze() \ No newline at end of file +internal inline fun Job.asNativeCancellable(): KontinuityCancellable = { cancel() } \ No newline at end of file diff --git a/kontinuity-core/src/commonMain/kotlin/io/mockative/kontinuity/internal/KontinuityFlow.kt b/kontinuity-core/src/commonMain/kotlin/io/mockative/kontinuity/internal/KontinuityFlow.kt index abc2531..7ba3b30 100644 --- a/kontinuity-core/src/commonMain/kotlin/io/mockative/kontinuity/internal/KontinuityFlow.kt +++ b/kontinuity-core/src/commonMain/kotlin/io/mockative/kontinuity/internal/KontinuityFlow.kt @@ -47,5 +47,5 @@ fun Flow.toKontinuityFlow(scope: CoroutineScope? = null): KontinuityFlow< job.asNativeCancellable() } - return flow.freeze() + return flow } \ No newline at end of file diff --git a/kontinuity-core/src/commonMain/kotlin/io/mockative/kontinuity/internal/KontinuityStateFlow.kt b/kontinuity-core/src/commonMain/kotlin/io/mockative/kontinuity/internal/KontinuityStateFlow.kt index 7209bd4..2930242 100644 --- a/kontinuity-core/src/commonMain/kotlin/io/mockative/kontinuity/internal/KontinuityStateFlow.kt +++ b/kontinuity-core/src/commonMain/kotlin/io/mockative/kontinuity/internal/KontinuityStateFlow.kt @@ -30,5 +30,5 @@ fun StateFlow.toKontinuityStateFlow(scope: CoroutineScope? = null): Konti } } - return stateFlow.freeze() + return stateFlow } \ No newline at end of file diff --git a/kontinuity-core/src/commonMain/kotlin/io/mockative/kontinuity/internal/KontinuitySuspend.kt b/kontinuity-core/src/commonMain/kotlin/io/mockative/kontinuity/internal/KontinuitySuspend.kt index e3f6af3..2d02e18 100644 --- a/kontinuity-core/src/commonMain/kotlin/io/mockative/kontinuity/internal/KontinuitySuspend.kt +++ b/kontinuity-core/src/commonMain/kotlin/io/mockative/kontinuity/internal/KontinuitySuspend.kt @@ -43,5 +43,5 @@ fun kontinuitySuspend(scope: CoroutineScope? = null, block: suspend () -> T) job.asNativeCancellable() } - return suspend.freeze() + return suspend } \ No newline at end of file diff --git a/kontinuity-core/src/darwinMain/kotlin/io/mockative/kontinuity/internal/KontinuityError.kt b/kontinuity-core/src/darwinMain/kotlin/io/mockative/kontinuity/internal/KontinuityError.kt index b4292ac..9eea716 100644 --- a/kontinuity-core/src/darwinMain/kotlin/io/mockative/kontinuity/internal/KontinuityError.kt +++ b/kontinuity-core/src/darwinMain/kotlin/io/mockative/kontinuity/internal/KontinuityError.kt @@ -9,7 +9,7 @@ actual typealias KontinuityError = NSError @OptIn(UnsafeNumber::class) internal actual fun Throwable.asKontinuityError(): KontinuityError { val userInfo = mutableMapOf() - userInfo["KotlinException"] = this.freeze() + userInfo["KotlinException"] = this val message = message if (message != null) { diff --git a/kontinuity-core/src/jsMain/kotlin/io/mockative/kontinuity/internal/Freeze.kt b/kontinuity-core/src/jsMain/kotlin/io/mockative/kontinuity/internal/Freeze.kt deleted file mode 100644 index c281592..0000000 --- a/kontinuity-core/src/jsMain/kotlin/io/mockative/kontinuity/internal/Freeze.kt +++ /dev/null @@ -1,3 +0,0 @@ -package io.mockative.kontinuity.internal - -actual fun T.freeze(): T = this \ No newline at end of file diff --git a/kontinuity-core/src/jvmMain/kotlin/io/mockative/kontinuity/internal/Freeze.kt b/kontinuity-core/src/jvmMain/kotlin/io/mockative/kontinuity/internal/Freeze.kt deleted file mode 100644 index c281592..0000000 --- a/kontinuity-core/src/jvmMain/kotlin/io/mockative/kontinuity/internal/Freeze.kt +++ /dev/null @@ -1,3 +0,0 @@ -package io.mockative.kontinuity.internal - -actual fun T.freeze(): T = this \ No newline at end of file diff --git a/kontinuity-core/src/nativeMain/kotlin/io/mockative/kontinuity/internal/Freeze.kt b/kontinuity-core/src/nativeMain/kotlin/io/mockative/kontinuity/internal/Freeze.kt deleted file mode 100644 index e8bd704..0000000 --- a/kontinuity-core/src/nativeMain/kotlin/io/mockative/kontinuity/internal/Freeze.kt +++ /dev/null @@ -1,5 +0,0 @@ -package io.mockative.kontinuity.internal - -import kotlin.native.concurrent.freeze - -actual fun T.freeze(): T = this.freeze() diff --git a/shared/build.gradle.kts b/shared/build.gradle.kts index 4f21d0a..6961270 100644 --- a/shared/build.gradle.kts +++ b/shared/build.gradle.kts @@ -49,7 +49,7 @@ kotlin { val commonMain by getting { dependencies { // KotlinX - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0-native-mt") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4") // Kontinuity implementation(project(":kontinuity-core")) @@ -62,7 +62,7 @@ kotlin { implementation(kotlin("test-common")) implementation(kotlin("test-annotations-common")) - implementation("io.mockative:mockative:1.2.1") + implementation("io.mockative:mockative:1.2.5") } } @@ -103,7 +103,7 @@ dependencies { configurations .filter { it.name.startsWith("ksp") && it.name.contains("Test") } .forEach { - add(it.name, "io.mockative:mockative-processor:1.2.1") + add(it.name, "io.mockative:mockative-processor:1.2.5") } } @@ -124,7 +124,7 @@ android { dependencies { androidTestImplementation("androidx.test:runner:1.4.0") - androidTestUtil("androidx.test:orchestrator:1.4.0") + androidTestUtil("androidx.test:orchestrator:1.4.1") } } diff --git a/shared/src/iosTest/kotlin/com/app/sample/AuthenticationServiceTests.kt b/shared/src/iosTest/kotlin/com/app/sample/AuthenticationServiceTests.kt index 3f3114a..f272bdf 100644 --- a/shared/src/iosTest/kotlin/com/app/sample/AuthenticationServiceTests.kt +++ b/shared/src/iosTest/kotlin/com/app/sample/AuthenticationServiceTests.kt @@ -34,7 +34,8 @@ class AuthenticationServiceTests { val mutex = Mutex() mutex.lock() - kAuthenticationService.loginK(request).invoke( + val kSuspend = kAuthenticationService.loginK(request) + kSuspend.invoke( { value, _ -> resultOrNull = Result.success(value) mutex.unlock()