https://kotlinlang.org logo
#arrow
Title
# arrow
r

Riccardo Cardin

10/27/2023, 11:56 AM
Hey, arrow fans. I released version 0.2.0 of the
assertj-arrow-core
library 🚀 . If you want the complete list of changes, check it out here. This version makes a new list of RaiseE assertions available 😍 . Say that you have a function in the
Raise<E>
context and want to know if it succeeded with a specific value. Nothing easier!
Copy code
context (Raise<String>)
fun aFunctionWithContext(input: Int): Int = input

@Test
internal fun `should pass if lambda succeeds with the given value`() {
    assertThat { aFunctionWithContext(42) }.succeedsWith(42)
}
Same thing if you want to check if the function fails with an specific error:
Copy code
context (Raise<String>)
fun aFunctionThatRaisesAnError(): Int = raise("LOGICAL ERROR")

@Test
internal fun `should pass if lambda raises a logical error`() {
    assertThat { aFunctionThatRaisesAnError() }.raises("LOGICAL ERROR")
}
Happy coding! 🎉
👏 3
arrow intensifies 3