in kotlinx-coroutines-test/jvm/src/migration/TestBuildersDeprecated.kt [162:187]
public fun runTestWithLegacyScope(
context: CoroutineContext = EmptyCoroutineContext,
dispatchTimeoutMs: Long = DEFAULT_DISPATCH_TIMEOUT_MS,
testBody: suspend TestCoroutineScope.() -> Unit
) {
if (context[RunningInRunTest] != null)
throw IllegalStateException("Calls to `runTest` can't be nested. Please read the docs on `TestResult` for details.")
val testScope = TestBodyCoroutine(createTestCoroutineScope(context + RunningInRunTest))
return createTestResult {
runTestCoroutineLegacy(
testScope,
dispatchTimeoutMs.milliseconds,
TestBodyCoroutine::tryGetCompletionCause,
testBody
) {
try {
testScope.cleanup()
emptyList()
} catch (e: UncompletedCoroutinesError) {
throw e
} catch (e: Throwable) {
listOf(e)
}
}
}
}