⚡ Sangsakala Proxy 🏠 Home
Skip to content

Two arbFs with same arguments always produce identical functions #314

Open

Description

@mrbackend

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?

Activity

  1. changed the title [-]arbF with same arguments always produces identical functions[/-] [+]Two arbFs with same arguments always produce identical functions[/+] on Feb 23, 2017
  2. mrbackend commented on Feb 23, 2017

    @mrbackend
    ContributorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions