Skip to content

Commit

Permalink
~improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
qwwdfsad committed Mar 30, 2022
1 parent 7048a1a commit 3ddac07
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
Expand Up @@ -7,7 +7,7 @@ import kotlinx.coroutines.*
import kotlinx.coroutines.exceptions.*
import kotlin.test.*

class LimitedParallelismSharedStressTest : TestBase() {
class LimitedParallelismConcurrentTest : TestBase() {

private val targetParallelism = 4
private val iterations = 100_000
Expand Down Expand Up @@ -41,4 +41,19 @@ class LimitedParallelismSharedStressTest : TestBase() {
}
}
}

@Test
fun testTaskFairness() = runTest {
val executor = newSingleThreadContext("test")
val view = executor.limitedParallelism(1)
val view2 = executor.limitedParallelism(1)
val j1 = launch(view) {
while (true) {
yield()
}
}
val j2 = launch(view2) { j1.cancel() }
joinAll(j1, j2)
executor.close()
}
}
Expand Up @@ -9,22 +9,7 @@ import java.util.concurrent.*
import kotlin.coroutines.*
import kotlin.test.*

class LimitedParallelismTest : TestBase() {

@Test
fun testTaskFairness() = runTest {
val executor = newSingleThreadContext("test")
val view = executor.limitedParallelism(1)
val view2 = executor.limitedParallelism(1)
val j1 = launch(view) {
while (true) {
yield()
}
}
val j2 = launch(view2) { j1.cancel() }
joinAll(j1, j2)
executor.close()
}
class LimitedParallelismUnhandledExceptionTest : TestBase() {

@Test
fun testUnhandledException() = runTest {
Expand Down

0 comments on commit 3ddac07

Please sign in to comment.