• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download

<lambda>null1 package kotlinx.coroutines.testing
2 
3 import kotlin.test.*
4 import kotlinx.coroutines.*
5 import kotlinx.coroutines.internal.*
6 
7 actual val VERBOSE = false
8 
9 actual typealias NoWasmWasi = Ignore
10 
11 actual val isStressTest: Boolean = false
12 actual val stressTestMultiplier: Int = 1
13 actual val stressTestMultiplierSqrt: Int = 1
14 
15 actual typealias TestResult = Unit
16 
17 internal actual fun lastResortReportException(error: Throwable) {
18     println(error)
19 }
20 
21 actual open class TestBase(
22     private val errorCatching: ErrorCatching.Impl
23 ): OrderedExecutionTestBase(), ErrorCatching by errorCatching {
24 
25     actual constructor(): this(errorCatching = ErrorCatching.Impl())
26 
printlnnull27     actual fun println(message: Any?) {
28         kotlin.io.println(message)
29     }
30 
runTestnull31     public actual fun runTest(
32         expected: ((Throwable) -> Boolean)?,
33         unhandled: List<(Throwable) -> Boolean>,
34         block: suspend CoroutineScope.() -> Unit
35     ): TestResult {
36         var exCount = 0
37         var ex: Throwable? = null
38         try {
39             runTestCoroutine(block = block, context = CoroutineExceptionHandler { _, e ->
40                 if (e is CancellationException) return@CoroutineExceptionHandler // are ignored
41                 exCount++
42                 when {
43                     exCount > unhandled.size ->
44                         error("Too many unhandled exceptions $exCount, expected ${unhandled.size}, got: $e", e)
45                     !unhandled[exCount - 1](e) ->
46                         error("Unhandled exception was unexpected: $e", e)
47                 }
48             })
49         } catch (e: Throwable) {
50             ex = e
51             if (expected != null) {
52                 if (!expected(e))
53                     error("Unexpected exception: $e", e)
54             } else
55                 throw e
56         } finally {
57             if (ex == null && expected != null) kotlin.error("Exception was expected but none produced")
58         }
59         if (exCount < unhandled.size)
60             kotlin.error("Too few unhandled exceptions $exCount, expected ${unhandled.size}")
61     }
62 }
63 
64 actual val isNative = false
65 
66 actual val isBoundByJsTestTimeout = true
67 
68 actual val isJavaAndWindows: Boolean get() = false
69 
70 actual val usesSharedEventLoop: Boolean = true
71