Skip to content
This repository was archived by the owner on Feb 2, 2025. It is now read-only.

Commit be6446f

Browse files
committed
feat: make raise matchers inline
avoids propagation of suspend when raise/recover no longer requires it
1 parent 4e6b8c0 commit be6446f

File tree

1 file changed

+3
-5
lines changed
  • kotest-assertions-arrow/src/commonMain/kotlin/io/kotest/assertions/arrow/core

1 file changed

+3
-5
lines changed

kotest-assertions-arrow/src/commonMain/kotlin/io/kotest/assertions/arrow/core/Raise.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import io.kotest.assertions.print.print
1717
* }
1818
* ```
1919
*/
20-
public suspend inline fun <reified T> shouldRaise(noinline block: suspend Raise<Any?>.() -> Any?): T {
20+
public inline fun <reified T> shouldRaise(noinline block: Raise<Any?>.() -> Any?): T {
2121
val expectedRaiseClass = T::class
2222
return recover({
2323
block()
@@ -40,10 +40,8 @@ public suspend inline fun <reified T> shouldRaise(noinline block: suspend Raise<
4040
* }
4141
* ```
4242
*/
43-
public suspend fun <T> shouldNotRaise(block: suspend Raise<Any?>.() -> T): T {
44-
return recover({
45-
block()
46-
}) { raised ->
43+
public inline fun <T> shouldNotRaise(block: Raise<Any?>.() -> T): T {
44+
return recover(block) { raised ->
4745
throw failure("No raise expected, but ${raised.print().value} was raised.")
4846
}
4947
}

0 commit comments

Comments
 (0)