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

Two arbFs with same arguments always produce identical functions #314

Open
mrbackend opened this issue Feb 23, 2017 · 1 comment
Open

Two arbFs with same arguments always produce identical functions #314

mrbackend opened this issue Feb 23, 2017 · 1 comment

Comments

@mrbackend
Copy link
Contributor

mrbackend commented Feb 23, 2017

Consider:

@RunWith(PropertyTestRunner.class)
public final class ArbFProperties {

    public Property arbFProperty() {
        return Property.property(
                Arbitrary.arbF(Cogen.cogenInteger, Arbitrary.arbInteger),
                Arbitrary.arbF(Cogen.cogenInteger, Arbitrary.arbInteger),
                Arbitrary.arbInteger,
                (f1, f2, arg) -> {
                    System.out.format("arg = %d, f1(arg) = %d, f2(arg) = %d%n", arg, f1.f(arg), f2.f(arg));
                    return Property.prop(true);
                });
    }

}

The functions always produce the same result. This seems to be intentional, the way arbF is programmed, but it is surprising to me. To create two independent functions, I have to use different cogenerators for the arguments (different arbitraries for the results are harder to make independent).

Is this a bug?

@mrbackend mrbackend changed the title arbF with same arguments always produces identical functions Two arbFs with same arguments always produce identical functions Feb 23, 2017
@mrbackend
Copy link
Contributor Author

A workaround that seems to work ok is:

...
Arbitrary.arbF(Cogen.cogenInteger, Arbitrary.arbInteger),
Arbitrary.arbF(Cogen.cogenInteger.<Integer>contramap(i -> i + 1), Arbitrary.arbInteger),
...

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

1 participant