Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor RaceNJvmTest from Kotest Plugin to Kotlin-test runtime #3261

Merged
merged 2 commits into from
Nov 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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({
}
}
}
)
Loading