Skip to content

Commit

Permalink
Add tests for short-circuiting fatal bracket
Browse files Browse the repository at this point in the history
  • Loading branch information
kyay10 committed Nov 1, 2024
1 parent 5d1a407 commit 8f441ec
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package arrow.fx.coroutines

import io.kotest.assertions.throwables.shouldThrow
import io.kotest.matchers.collections.shouldBeEmpty
import io.kotest.matchers.shouldBe
import kotlinx.coroutines.test.runTest
import kotlin.test.DefaultAsserter.fail
import kotlin.test.Test

class BracketCaseJvmTest {
@Test
fun blowBracketOnFatal() = runTest {
val error = shouldThrow<LinkageError> {
bracket({ }, { throw LinkageError("BOOM!") }) { fail("Should never come here") }
}
error.message shouldBe "BOOM!"
error.suppressedExceptions.shouldBeEmpty()
}

@Test
fun blowBracketOnFatalInRelease() = runTest {
val error = shouldThrow<LinkageError> {
bracket({ }, { throw RuntimeException() }) { throw LinkageError("BOOM!") }
}
error.message shouldBe "BOOM!"
error.suppressedExceptions.shouldBeEmpty()
}
}

0 comments on commit 8f441ec

Please sign in to comment.