Skip to content

Commit

Permalink
Refactor RaceNJvmTest from Kotest Plugin to Kotlin-test runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
chrsblck committed Oct 30, 2023
1 parent 6b794a9 commit ad47002
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ package arrow.fx.coroutines

import arrow.core.Either
import arrow.core.identity
import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.should
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.awaitCancellation
import kotlinx.coroutines.test.runTest
import kotlinx.coroutines.withContext
import kotlin.test.Test

class RaceNJvmTest : StringSpec({
"race2 returns to original context" {
class RaceNJvmTest {
@Test fun race2ReturnsToOriginalContext() = runTest {
val racerName = "race2"
checkAll(Arb.int(1..2)) { choose ->
resourceScope {
Expand All @@ -31,8 +32,8 @@ class RaceNJvmTest : StringSpec({
}
}
}
"race2 returns to original context on failure" {

@Test fun race2ReturnsToOriginalContextOnFailure() = runTest {
val racerName = "race2"

checkAll(Arb.int(1..2), Arb.throwable()) { choose, e ->
Expand All @@ -54,14 +55,14 @@ class RaceNJvmTest : StringSpec({
}
}

"first racer out of 2 always wins on a single thread" {
@Test fun firstRacerOutOf2AlwaysWinsOnASingleThread() = runTest {
resourceScope {
val ctx = singleThreadContext("single")
raceN(ctx, { Thread.currentThread().name }, { Thread.currentThread().name })
}.swap().getOrNull() shouldStartWith "single"
}

"race3 returns to original context" {
@Test fun race3ReturnsToOriginalContext() = runTest {
val racerName = "race3"

checkAll(Arb.int(1..3)) { choose ->
Expand Down Expand Up @@ -90,7 +91,7 @@ class RaceNJvmTest : StringSpec({
}
}

"race3 returns to original context on failure" {
@Test fun race3ReturnsToOriginalContextOnFailure() = runTest {
val racerName = "race3"

checkAll(Arb.int(1..3), Arb.throwable()) { choose, e ->
Expand Down Expand Up @@ -120,4 +121,3 @@ class RaceNJvmTest : StringSpec({
}
}
}
)

0 comments on commit ad47002

Please sign in to comment.