-
Notifications
You must be signed in to change notification settings - Fork 88
Closed
Description
It would be nice to have a module with extra support for Arrow library: https://arrow-kt.io/ similar to what Kotest has: https://github.com/kotest/kotest/blob/master/doc/matchers/arrow.md
Here are some of them you are free to add:
/**
* Asserts the Either value is Either.Right. You can pass in an optional lambda to run additional assertions on the right value
*
* ```
* val name = Either.Right("...")
* assertThat(name).isRight().hasLength(3)
* ```
*/
fun <B : Any> Assert<Either<*, B>>.isRight(): Assert<B> = transform { actual ->
actual.getOrElse { expected("to be right") }
}
/**
* Asserts the Either value is Either.Left. You can pass in an optional lambda to run additional assertions on the left value
*
* ```
* val name = Either.Left("...")
* assertThat(name).isLeft().hasLength(3)
* ```
*/
fun <A : Any> Assert<Either<A, *>>.isLeft(): Assert<A> = transform { actual ->
actual.swap().getOrElse { expected("to be left") }
}
Metadata
Metadata
Assignees
Labels
No labels