Skip to content

Commit 3ddac07

Browse files
committed
~improve tests
1 parent 7048a1a commit 3ddac07

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

kotlinx-coroutines-core/concurrent/test/LimitedParallelismSharedStressTest.kt renamed to kotlinx-coroutines-core/concurrent/test/LimitedParallelismConcurrentTest.kt

+16-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import kotlinx.coroutines.*
77
import kotlinx.coroutines.exceptions.*
88
import kotlin.test.*
99

10-
class LimitedParallelismSharedStressTest : TestBase() {
10+
class LimitedParallelismConcurrentTest : TestBase() {
1111

1212
private val targetParallelism = 4
1313
private val iterations = 100_000
@@ -41,4 +41,19 @@ class LimitedParallelismSharedStressTest : TestBase() {
4141
}
4242
}
4343
}
44+
45+
@Test
46+
fun testTaskFairness() = runTest {
47+
val executor = newSingleThreadContext("test")
48+
val view = executor.limitedParallelism(1)
49+
val view2 = executor.limitedParallelism(1)
50+
val j1 = launch(view) {
51+
while (true) {
52+
yield()
53+
}
54+
}
55+
val j2 = launch(view2) { j1.cancel() }
56+
joinAll(j1, j2)
57+
executor.close()
58+
}
4459
}

kotlinx-coroutines-core/jvm/test/LimitedParallelismTest.kt renamed to kotlinx-coroutines-core/jvm/test/LimitedParallelismUnhandledExceptionTest.kt

+1-16
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,7 @@ import java.util.concurrent.*
99
import kotlin.coroutines.*
1010
import kotlin.test.*
1111

12-
class LimitedParallelismTest : TestBase() {
13-
14-
@Test
15-
fun testTaskFairness() = runTest {
16-
val executor = newSingleThreadContext("test")
17-
val view = executor.limitedParallelism(1)
18-
val view2 = executor.limitedParallelism(1)
19-
val j1 = launch(view) {
20-
while (true) {
21-
yield()
22-
}
23-
}
24-
val j2 = launch(view2) { j1.cancel() }
25-
joinAll(j1, j2)
26-
executor.close()
27-
}
12+
class LimitedParallelismUnhandledExceptionTest : TestBase() {
2813

2914
@Test
3015
fun testUnhandledException() = runTest {

0 commit comments

Comments
 (0)