Skip to content

Commit 2e1d03e

Browse files
committed
[raise-dsl-assertions] Documentation
1 parent 0e4d09a commit 2e1d03e

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

src/main/kotlin/in/rcard/assertj/arrowcore/AbstractEitherAssert.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ abstract class AbstractEitherAssert<
8888
*
8989
* @param requirement the consumer that will accept the right-sided value for deep asserting.
9090
* @return this assertion object.
91+
*
92+
* @since 0.1.0
9193
*/
9294
fun hasRightValueSatisfying(requirement: (RIGHT) -> Unit): SELF {
9395
assertIsRight()
@@ -142,6 +144,7 @@ abstract class AbstractEitherAssert<
142144
*
143145
* @param requirement the consumer that will accept the left-sided value for deep asserting.
144146
* @return this assertion object.
147+
* @since 0.1.0
145148
*/
146149
fun hasLeftValueSatisfying(requirement: (LEFT) -> Unit): SELF {
147150
assertIsLeft()

src/main/kotlin/in/rcard/assertj/arrowcore/AbstractOptionAssert.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ abstract class AbstractOptionAssert<
9292
*
9393
* @param requirement to further assert on the object contained inside the [Option].
9494
* @return this assertion object.
95+
* @since 0.1.0
9596
*/
9697
fun hasValueSatisfying(requirement: (VALUE) -> Unit): SELF {
9798
assertValueIsPresent()

src/main/kotlin/in/rcard/assertj/arrowcore/AbstractRaiseAssert.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ import org.assertj.core.api.AbstractAssert
1010
import org.assertj.core.internal.ComparisonStrategy
1111
import org.assertj.core.internal.StandardComparisonStrategy
1212

13+
/**
14+
* Assertions for functions within a [Raise] context.
15+
*
16+
* @param VALUE type of the value returned by the function.
17+
* @param ERROR type of the logical error raised by the function.
18+
* @author Riccardo Cardin
19+
*
20+
* @since 0.2.0
21+
*/
1322
abstract class AbstractRaiseAssert<
1423
SELF : AbstractRaiseAssert<SELF, ERROR, VALUE>, ERROR : Any, VALUE : Any,
1524
>(lambda: context(Raise<ERROR>) () -> VALUE) :

src/main/kotlin/in/rcard/assertj/arrowcore/RaiseAssert.kt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,32 @@ import org.assertj.core.api.Assertions
1010
import org.assertj.core.internal.Failures
1111
import kotlin.experimental.ExperimentalTypeInference
1212

13+
/**
14+
* Assertions for functions within a [Raise] context.
15+
*
16+
* @param VALUE type of the value returned by the function.
17+
* @param ERROR type of the logical error raised by the function.
18+
* @author Riccardo Cardin
19+
*
20+
* @since 0.2.0
21+
*/
1322
class RaiseAssert<ERROR : Any, VALUE : Any> private constructor(lambda: Raise<ERROR>.() -> VALUE) :
1423
AbstractRaiseAssert<RaiseAssert<ERROR, VALUE>, ERROR, VALUE>(lambda) {
1524
companion object {
16-
fun <ERROR : Any, VALUE : Any> assertThat(@BuilderInference lambda: Raise<ERROR>.() -> VALUE): RaiseAssert<ERROR, VALUE> =
25+
fun <ERROR : Any, VALUE : Any> assertThat(
26+
@BuilderInference lambda: Raise<ERROR>.() -> VALUE
27+
): RaiseAssert<ERROR, VALUE> =
1728
RaiseAssert(lambda)
1829

19-
fun <ERROR : Any, VALUE : Any> assertThatThrownBy(@BuilderInference shouldRaiseThrowable: Raise<ERROR>.() -> VALUE): AbstractThrowableAssert<*, out Throwable> {
30+
fun <ERROR : Any, VALUE : Any> assertThatThrownBy(
31+
@BuilderInference shouldRaiseThrowable: Raise<ERROR>.() -> VALUE
32+
): AbstractThrowableAssert<*, out Throwable> {
2033
val throwable: Throwable? = fold(block = shouldRaiseThrowable,
2134
recover = { null },
2235
transform = { null },
2336
catch = { exception -> exception })
2437

38+
@Suppress("KotlinConstantConditions")
2539
return throwable?.let { return Assertions.assertThat(throwable) } ?: throw Failures.instance()
2640
.failure(Assertions.assertThat(throwable).writableAssertionInfo, shouldThrowAnException())
2741
}

0 commit comments

Comments
 (0)