dave08
05/02/2021, 3:15 PMinline fun <V, reified E> Assertion.Builder<Result<V, E>>.isFailureOf(): Assertion.Builder<E> =
assert("is failure of type ${E::class.simpleName}") {
when {
it is Err -> pass(
description = "threw %s",
actual = it.error
)
else -> fail(
description = "returned %s",
actual = it.get()
)
}
}
.get("exception") {
unwrapError()
}
But still won't give me the actual E
I want only the base class of it. Ideally I'd like to provide one type param, and have it report that name in the assert... but it seems like Kotlin won't let me use * for the V
in Result
...dave08
05/02/2021, 3:32 PMinline fun <BE, reified E : BE> Assertion.Builder<Result<*, BE>>.isFailureOf(): Assertion.Builder<E> =
assert("is failure of type ${E::class.simpleName}") {
when {
it is Err -> pass(
description = "threw %s",
actual = it.error
)
else -> fail(
description = "returned %s",
actual = it.get()
)
}
}
.get("exception") {
unwrapError() as E
}
SimonT
05/02/2021, 4:58 PMexpect {
response.mapRight {
that(it) {
get { this }.isEqualTo(fakeBeerListModel)
}
}
So one possibility is adding mapRight, mapLeft extension functions and using them