https://kotlinlang.org logo
#kotest
Title
# kotest
d

dave08

03/11/2024, 4:08 PM
Funny, I thought propery testing's
forAll
allows using suspend funs in it's lambda? It seems like not though... even though forAll itself is a suspend fun...
s

sam

03/11/2024, 4:14 PM
Yeah it does, cos its inline
so it inherits the suspend from the outer function
d

dave08

03/11/2024, 4:16 PM
When I tried, the IDE complained that I can't call a suspend fun outside a coroutine context, but when I used checkAll it works...
I'm on 5.8.0
Copy code
public suspend inline fun <reified A> checkAll(noinline property: suspend io.kotest.property.PropertyContext.(A) -> kotlin.Unit): io.kotest.property.PropertyContext
Copy code
public suspend inline fun <reified A> forAll(crossinline property: io.kotest.property.PropertyContext.(A) -> kotlin.Boolean): io.kotest.property.PropertyContext
It seems like that forAll overload doesn't have suspend, just crossinline...
s

sam

03/11/2024, 4:19 PM
oh right, interesting
d

dave08

03/11/2024, 4:20 PM
I get this:
Suspension functions can be called only within coroutine body
2 Views