Skip to content

Commit 46b5ea5

Browse files
committed
Tests that run from within a worker
1 parent 6fad018 commit 46b5ea5

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
package kotlinx.coroutines
6+
7+
import kotlin.coroutines.*
8+
import kotlin.native.concurrent.*
9+
import kotlin.test.*
10+
11+
class WorkerTest : TestBase() {
12+
13+
@Test
14+
fun testLaunchInWorker() {
15+
val worker = Worker.start()
16+
worker.execute(TransferMode.SAFE, { }) {
17+
runBlocking {
18+
launch { }.join()
19+
delay(1)
20+
}
21+
}.result
22+
}
23+
24+
@Test
25+
fun testLaunchInWorkerTroughGlobalScope() {
26+
val worker = Worker.start()
27+
worker.execute(TransferMode.SAFE, { }) {
28+
runBlocking {
29+
CoroutineScope(EmptyCoroutineContext).launch {
30+
delay(1)
31+
}.join()
32+
}
33+
}.result
34+
}
35+
}

0 commit comments

Comments
 (0)