Skip to content

Commit

Permalink
Refactor ParMapJvmTest from Kotest Plugin to Kotlin-test runtime (#3260)
Browse files Browse the repository at this point in the history
Closes #3203
  • Loading branch information
chrsblck authored Nov 2, 2023
1 parent 4ff4722 commit 092838f
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package arrow.fx.coroutines

import io.kotest.assertions.fail
import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.string.shouldStartWith
import io.kotest.property.Arb
import io.kotest.property.arbitrary.int
import io.kotest.property.checkAll
import kotlinx.coroutines.test.runTest
import kotlin.test.Test

class ParMapJvmTest : StringSpec({
"parMap runs on provided context" { // 100 is same default length as Arb.list
class ParMapJvmTest {
@Test fun parMapRunsOnProvidedContext() = runTest { // 100 is same default length as Arb.list
checkAll(Arb.int(min = Int.MIN_VALUE, max = 100)) { i ->
val res = resourceScope {
(0 until i).parMap(single()) { Thread.currentThread().name }
Expand All @@ -17,7 +18,7 @@ class ParMapJvmTest : StringSpec({
}
}

"parMap(concurrency = 3) runs on provided context" {
@Test fun parMapConcurrency3RunsOnProvidedContext() = runTest {
checkAll(Arb.int(min = Int.MIN_VALUE, max = 100)) { i ->
val res = resourceScope {
(0 until i).parMap(single(), concurrency = 3) {
Expand All @@ -28,7 +29,7 @@ class ParMapJvmTest : StringSpec({
}
}

"parMapOrAccumulate(combine = emptyError) runs on provided context" { // 100 is same default length as Arb.list
@Test fun parMapOrAccumulateCombineEmptyErrorRunsOnProvidedContext() = runTest { // 100 is same default length as Arb.list
checkAll(Arb.int(min = Int.MIN_VALUE, max = 100)) { i ->
val res = resourceScope {
(0 until i).parMapOrAccumulate<Nothing, Int, String>(single(), combine = emptyError) { Thread.currentThread().name }
Expand All @@ -40,7 +41,7 @@ class ParMapJvmTest : StringSpec({
}
}

"parMapOrAccumulate(combine = emptyError, concurrency = 3) runs on provided context" { // 100 is same default length as Arb.list
@Test fun parMapOrAccumulateCombineEmptyErrorConcurrency3RunsOnProvidedContext() = runTest { // 100 is same default length as Arb.list
checkAll(Arb.int(min = Int.MIN_VALUE, max = 100)) { i ->
val res = resourceScope {
(0 until i).parMapOrAccumulate<Nothing, Int, String>(
Expand All @@ -56,7 +57,7 @@ class ParMapJvmTest : StringSpec({
}
}

"parMapOrAccumulate runs on provided context" { // 100 is same default length as Arb.list
@Test fun parMapOrAccumulateRunsOnProvidedContext() = runTest { // 100 is same default length as Arb.list
checkAll(Arb.int(min = Int.MIN_VALUE, max = 100)) { i ->
val res = resourceScope {
(0 until i).parMapOrAccumulate<Nothing, Int, String>(single()) {
Expand All @@ -70,7 +71,7 @@ class ParMapJvmTest : StringSpec({
}
}

"parMapOrAccumulate(concurrency = 3) runs on provided context" { // 100 is same default length as Arb.list
@Test fun parMapOrAccumulateConcurrency3RunsOnProvidedContext() = runTest { // 100 is same default length as Arb.list
checkAll(Arb.int(min = Int.MIN_VALUE, max = 100)) { i ->

val res = resourceScope {
Expand All @@ -84,7 +85,7 @@ class ParMapJvmTest : StringSpec({
)
}
}
})
}

private val emptyError: (Nothing, Nothing) -> Nothing =
{ _, _ -> throw AssertionError("Should not be called") }
Expand Down

0 comments on commit 092838f

Please sign in to comment.