Skip to content

Commit

Permalink
Make a test configuration-independent (#4172)
Browse files Browse the repository at this point in the history
Fixes #4153
  • Loading branch information
dkhalanskyjb authored Jul 15, 2024
1 parent 73f153d commit 12f36aa
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions kotlinx-coroutines-core/jvm/test/DispatchersToStringTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

package kotlinx.coroutines

import kotlinx.coroutines.scheduling.CORE_POOL_SIZE
import kotlinx.coroutines.scheduling.MAX_POOL_SIZE
import kotlin.test.*

class DispatchersToStringTest {
Expand All @@ -16,8 +18,16 @@ class DispatchersToStringTest {

@Test
fun testLimitedParallelism() {
assertEquals("Dispatchers.IO.limitedParallelism(1)", Dispatchers.IO.limitedParallelism(1).toString())
assertEquals("Dispatchers.Default.limitedParallelism(2)", Dispatchers.Default.limitedParallelism(2).toString())
for (parallelism in 1..100) {
assertEquals(
"Dispatchers.IO" + if (parallelism < MAX_POOL_SIZE) ".limitedParallelism($parallelism)" else "",
Dispatchers.IO.limitedParallelism(parallelism).toString()
)
assertEquals(
"Dispatchers.Default" + if (parallelism < CORE_POOL_SIZE) ".limitedParallelism($parallelism)" else "",
Dispatchers.Default.limitedParallelism(parallelism).toString()
)
}
// Not overridden at all, limited parallelism returns `this`
assertEquals("DefaultExecutor", (DefaultDelay as CoroutineDispatcher).limitedParallelism(42).toString())

Expand Down

0 comments on commit 12f36aa

Please sign in to comment.