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.bind produces the same value for property test #1348

Closed
ataronet opened this issue Apr 3, 2020 · 2 comments · Fixed by #1350
Closed

Arb.bind produces the same value for property test #1348

ataronet opened this issue Apr 3, 2020 · 2 comments · Fixed by #1350

Comments

@ataronet
Copy link
Contributor

ataronet commented Apr 3, 2020

"test test" {
            checkAll(Arb.bind(
                Arb.bool(),
                Arb.int()
            ) {first, second -> Pair(first, second)}
            ){
                println("TEST TEST TEST ${it}")
            }
        }```
Gives back the result of 

TEST TEST TEST (true, 0)
TEST TEST TEST (true, 0)
TEST TEST TEST (true, 0)
TEST TEST TEST (true, 0)
TEST TEST TEST (true, 0)
TEST TEST TEST (true, 0)
TEST TEST TEST (true, 0)
TEST TEST TEST (true, 0)

Please advice how to bind 2, 3, n values together (like zip) in order to create different combinations.
Thank you
@ataronet
Copy link
Contributor Author

ataronet commented Apr 3, 2020

I also think I fixed the bug here:

fun <A, B, T : Any> Arb.Companion.bind2(genA: Gen<A>, genB: Gen<B>, bindFn: (A, B) -> T): Arb<T> = arb {
    val seqA = genA.generate(it)
    val seqB = genB.generate(it)
    val iteratorA = seqA.iterator()
    val iteratorB = seqB.iterator()
    generateSequence {
        val a = iteratorA.next()
        val b = iteratorB.next()
        bindFn(a.value, b.value)
    }
}```

@sksamuel
Copy link
Member

sksamuel commented Apr 3, 2020

Fix pending.

sksamuel added a commit that referenced this issue Apr 3, 2020
* Arb.bind produces the same value for property test #1348
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

Successfully merging a pull request may close this issue.

2 participants