Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arb.choice should take Arb instances and not combine edgecases into arb.values(). #1406

Closed
jaymoid opened this issue Apr 24, 2020 · 0 comments

Comments

@jaymoid
Copy link
Contributor

jaymoid commented Apr 24, 2020

Currently Arb.choice takes Gen instances as parameters and combines the edgecases and the arb values. Such that you get the edgecases first when you call .values() on the resulting Arb instance. In addition the edgecases in the passed in Arbs are not available via the edgecases() function on the resulting Arb, instead you get an empty list.

As this might might not be expected, and invoking choice on an Exhaustive is counter intuitive, after discussing with @sksamuel in slack, it's been suggested that we:

  • Change Arb.choice to accept vararg Arb<A>
  • Combine the edgecases from the provided Arbs, and make available via resulting Arb.edgecases
  • Expect values from the provided Arb instances to be available via the resulting .values()
  • deprecate the existing one and replace it with the below
  • Use @JvmName to keep the same function name with the varargs
    Something like:
fun <A> Arb.Companion.choice(vararg arbs: Arb<A>): Arb<A> = arb (arbs.flatMap(Arb<A>::edgecases)){ rs ->
    val iters = arbs.map { it.values(rs).iterator() }
...

I'm happy to have a go at this.

jaymoid pushed a commit to jaymoid/kotest that referenced this issue Apr 25, 2020
@jaymoid jaymoid changed the title Arb.choice should take Arb instances and not combines edge cases and values. Arb.choice should take Arb instances and not combine edgecases into arb.values(). Apr 25, 2020
sksamuel pushed a commit that referenced this issue Apr 25, 2020
sksamuel pushed a commit that referenced this issue Apr 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants