Skip to content

Commit 4b9ae98

Browse files
committed
Simpler workaround for missing suspend tests (see KT-22228):
declare dynamic result for runTest in JS
1 parent f066fe9 commit 4b9ae98

File tree

3 files changed

+3
-13
lines changed
  • common/kotlinx-coroutines-core-common/src/test/kotlin/kotlinx/coroutines/experimental
  • core/kotlinx-coroutines-core/src/test/kotlin/kotlinx/coroutines/experimental
  • js/kotlinx-coroutines-core-js/src/test/kotlin/kotlinx/coroutines/experimental

3 files changed

+3
-13
lines changed

common/kotlinx-coroutines-core-common/src/test/kotlin/kotlinx/coroutines/experimental/CommonTestBase.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,5 @@ public expect open class TestBase constructor() {
3131
expected: ((Throwable) -> Boolean)? = null,
3232
unhandled: List<(Throwable) -> Boolean> = emptyList(),
3333
block: suspend CoroutineScope.() -> Unit
34-
): TestResult
34+
)
3535
}
36-
37-
// todo: This is a work-around for missing suspend tests, see KT-22228
38-
@Suppress("NO_ACTUAL_FOR_EXPECT")
39-
expect class TestResult

core/kotlinx-coroutines-core/src/test/kotlin/kotlinx/coroutines/experimental/TestBase.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,3 @@ public actual open class TestBase actual constructor() {
149149
error("Too few unhandled exceptions $exCount, expected ${unhandled.size}")
150150
}
151151
}
152-
153-
@Suppress("ACTUAL_WITHOUT_EXPECT")
154-
actual typealias TestResult = Unit

js/kotlinx-coroutines-core-js/src/test/kotlin/kotlinx/coroutines/experimental/TestBase.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,12 @@ public actual open class TestBase actual constructor() {
6161
finished = true
6262
}
6363

64+
// todo: The dynamic (promise) result is a work-around for missing suspend tests, see KT-22228
6465
public actual fun runTest(
6566
expected: ((Throwable) -> Boolean)? = null,
6667
unhandled: List<(Throwable) -> Boolean> = emptyList(),
6768
block: suspend CoroutineScope.() -> Unit
68-
): TestResult {
69+
): dynamic {
6970
var exCount = 0
7071
var ex: Throwable? = null
7172
return promise(block = block, context = CoroutineExceptionHandler { context, e ->
@@ -95,7 +96,3 @@ public actual open class TestBase actual constructor() {
9596

9697
private fun <T> Promise<T>.finally(block: () -> Unit): Promise<T> =
9798
then(onFulfilled = { value -> block(); value }, onRejected = { ex -> block(); throw ex })
98-
99-
// todo: This is a work-around for missing suspend tests, see KT-22228
100-
@Suppress("ACTUAL_TYPE_ALIAS_TO_CLASS_WITH_DECLARATION_SITE_VARIANCE", "ACTUAL_WITHOUT_EXPECT")
101-
actual typealias TestResult = Promise<Any?>

0 commit comments

Comments
 (0)