Skip to content

Commit

Permalink
refactor: migrate TraceSpec to kotlin-test
Browse files Browse the repository at this point in the history
  • Loading branch information
milgner committed Oct 29, 2023
1 parent 6b794a9 commit abd607b
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,26 @@ package arrow.core.raise

import arrow.core.right
import io.kotest.assertions.throwables.shouldThrow
import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.shouldBe
import io.kotest.property.Arb
import io.kotest.property.arbitrary.int
import io.kotest.property.arbitrary.string
import io.kotest.property.checkAll
import kotlin.test.Test
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.test.runTest

@OptIn(ExperimentalTraceApi::class)
class TraceSpec : StringSpec({
"trace is empty when no errors" {
class TraceSpec {
@Test fun traceIsEmptyWhenNoErrors() = runTest {
checkAll(Arb.int()) { i ->
either<Nothing, Int> {
traced({ i }) { _,_ -> unreachable() }
} shouldBe i.right()
}
}

"trace is empty with exception" {
@Test fun traceIsEmptyWithException() = runTest {
checkAll(Arb.string()) { msg ->
val error = RuntimeException(msg)
shouldThrow<RuntimeException> {
Expand All @@ -31,7 +32,7 @@ class TraceSpec : StringSpec({
}
}

"nested tracing - identity" {
@Test fun nestedTracingIdentity() = runTest {
val inner = CompletableDeferred<String>()
ior(String::plus) {
traced({
Expand All @@ -43,4 +44,4 @@ class TraceSpec : StringSpec({
}
}
}
})
}

0 comments on commit abd607b

Please sign in to comment.