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

Commit a44d2c9

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

File tree

1 file changed

+4
-6
lines changed
  • kotest-assertions-arrow/src/commonMain/kotlin/io/kotest/assertions/arrow/core

1 file changed

+4
-6
lines changed

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ 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(block: Raise<Any?>.() -> Any?): T {
2121
val expectedRaiseClass = T::class
2222
return recover({
23-
block()
23+
block(this)
2424
throw failure("Expected to raise ${expectedRaiseClass.simpleName} but nothing was raised.")
2525
}) { raised ->
2626
when (raised) {
@@ -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)