I have an analog to Arrow's `Either` type, and I'd...
# kotest
j
I have an analog to Arrow's
Either
type, and I'd really like to do something like
Copy code
val actual: <Unit, Errorish> = doThing()

withClue(lazy { "doThing error: ${actual.errorOrNull()?.message}" }) { 
  actual.isOk shouldBe true
}
Is this possible and I'm just not seeing a way in the current matchers? Basically I don't want to try to get the error message unless there's an error in my value
for context I can't use v0.x.x and therefore the kotest arrow integration until v1.0.0 which hopefully is coming soon per: https://www.47deg.com/blog/arrow-0-11-0-release/
s
A clue that takes a lazy might be very nice
j
another thing for 4.4? 😈
s
You're keeping me busy
j
😂 😅
Thought was brought to you by inspiration from kotlin's
require
and
assert
Although it looks like asClue will pop every clue instead of only doing it when it fails, so it might need to be something similar to a clue, but not exactly
🤔
s
asClue on lazy will work
j
Copy code
(lazy { computeErrorMessage() }).asClue { 
  thing shouldBe true
}
like that?
s
I mean that will work once we add it
j
ah 👍
j
Is ErrorCollector part of the public facing api? I feel like changing pushClue to accept a Lazy<T> instead of a T is a breaking change
s
It's not public, or shouldn't be
its used internally
j
gotcha 👍