Make runBlockingTest match signature of kotlinx-coroutines-test
This commit is contained in:
parent
a76768fa42
commit
b123921ba5
@ -43,7 +43,7 @@ internal class SuspendableResultBindingImpl<E> : SuspendableResultBinding<E> {
|
||||
is Ok -> value
|
||||
is Err -> {
|
||||
mutex.withLock {
|
||||
if (::internalError.isInitialized.not()){
|
||||
if (::internalError.isInitialized.not()) {
|
||||
internalError = this
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,14 @@
|
||||
package com.github.michaelbull.result.coroutines
|
||||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.coroutines.EmptyCoroutineContext
|
||||
|
||||
/**
|
||||
* Workaround to use suspending functions in unit tests for multiplatform/native projects.
|
||||
* Solution was found here: https://github.com/Kotlin/kotlinx.coroutines/issues/885#issuecomment-446586161
|
||||
*/
|
||||
expect fun runBlockingTest(block: suspend (scope : CoroutineScope) -> Unit)
|
||||
expect fun runBlockingTest(
|
||||
context: CoroutineContext = EmptyCoroutineContext,
|
||||
testBody: suspend CoroutineScope.() -> Unit
|
||||
)
|
||||
|
@ -2,5 +2,10 @@ package com.github.michaelbull.result.coroutines
|
||||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
actual fun runBlockingTest(block: suspend (scope : CoroutineScope) -> Unit) = runBlocking { block(this) }
|
||||
actual fun runBlockingTest(context: CoroutineContext, testBody: suspend CoroutineScope.() -> Unit) {
|
||||
runBlocking {
|
||||
testBody(this)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user