diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/arrow/fx/coroutines/BracketCaseJvmTest.kt b/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/arrow/fx/coroutines/BracketCaseJvmTest.kt new file mode 100644 index 00000000000..4eba484065c --- /dev/null +++ b/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/arrow/fx/coroutines/BracketCaseJvmTest.kt @@ -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 { + bracket({ }, { throw LinkageError("BOOM!") }) { fail("Should never come here") } + } + error.message shouldBe "BOOM!" + error.suppressedExceptions.shouldBeEmpty() + } + + @Test + fun blowBracketOnFatalInRelease() = runTest { + val error = shouldThrow { + bracket({ }, { throw RuntimeException() }) { throw LinkageError("BOOM!") } + } + error.message shouldBe "BOOM!" + error.suppressedExceptions.shouldBeEmpty() + } +}