File tree 2 files changed +8
-2
lines changed
2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change 5
5
package kotlinx.coroutines.test
6
6
7
7
import kotlinx.coroutines.*
8
+ import kotlinx.coroutines.flow.*
8
9
import kotlin.coroutines.*
9
10
import kotlin.test.*
10
11
import kotlin.time.*
11
12
12
- class TestRunTest {
13
+ class RunTestTest {
13
14
15
+ /* * Tests that [withContext] that sends work to other threads works in [runTest]. */
14
16
@Test
15
17
fun testWithContextDispatching () = runTest {
16
18
var counter = 0
@@ -20,6 +22,7 @@ class TestRunTest {
20
22
assertEquals(counter, 1 )
21
23
}
22
24
25
+ /* * Tests that joining [GlobalScope.launch] works in [runTest]. */
23
26
@Test
24
27
fun testJoiningForkedJob () = runTest {
25
28
var counter = 0
@@ -30,14 +33,16 @@ class TestRunTest {
30
33
assertEquals(counter, 1 )
31
34
}
32
35
36
+ /* * Tests [suspendCoroutine] not failing [runTest]. */
33
37
@Test
34
- fun testSuspendCancellableCoroutine () = runTest {
38
+ fun testSuspendCoroutine () = runTest {
35
39
val answer = suspendCoroutine<Int > {
36
40
it.resume(42 )
37
41
}
38
42
assertEquals(42 , answer)
39
43
}
40
44
45
+ /* * Tests that [runTest] attempts to detect it being run inside another [runTest] and failing in such scenarios. */
41
46
@Test
42
47
fun testNestedRunTestForbidden () = runTest {
43
48
assertFailsWith<IllegalStateException > {
Original file line number Diff line number Diff line change @@ -88,6 +88,7 @@ class MultithreadingTest {
88
88
}
89
89
}
90
90
91
+ /* * Tests that resuming the coroutine of [runTest] asynchronously in reasonable time succeeds. */
91
92
@Test
92
93
fun testResumingFromAnotherThread () = runTest {
93
94
suspendCancellableCoroutine<Unit > { cont ->
You can’t perform that action at this time.
0 commit comments