-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for short-circuiting fatal bracket
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
...-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/arrow/fx/coroutines/BracketCaseJvmTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} |