-
Notifications
You must be signed in to change notification settings - Fork 449
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import io.kotest.property.arbitrary.bind | |
import io.kotest.property.arbitrary.boolean | ||
import io.kotest.property.arbitrary.choice | ||
import io.kotest.property.arbitrary.constant | ||
import io.kotest.property.arbitrary.filter | ||
import io.kotest.property.arbitrary.int | ||
import io.kotest.property.arbitrary.list | ||
import io.kotest.property.arbitrary.set | ||
|
@@ -29,7 +30,9 @@ import kotlin.coroutines.startCoroutine | |
// copied from kotest-extensions-arrow | ||
|
||
fun <A> Arb.Companion.nonEmptyList(arb: Arb<A>, range: IntRange = 0 .. 100): Arb<NonEmptyList<A>> = | ||
Arb.list(arb, max(range.first, 1) .. range.last).map { NonEmptyList(it) } | ||
Arb.list(arb, max(range.first, 1) .. range.last) | ||
.filter { it.isNotEmpty() } | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
nomisRev
Author
Member
|
||
.map { NonEmptyList(it) } | ||
|
||
fun <A> Arb.Companion.nonEmptySet(arb: Arb<A>, range: IntRange = 0 .. 100): Arb<NonEmptySet<A>> = | ||
Arb.set(arb, max(range.first, 1) .. range.last).map { it.toNonEmptySetOrNull()!! } | ||
|
Is that not covered by the start of the range being at least 1?
It might make the code intent clearer to use
coerceAtLeast
btw