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

Support OpenJML for Arbitraries #486

Open
jlink opened this issue May 26, 2023 · 0 comments
Open

Support OpenJML for Arbitraries #486

jlink opened this issue May 26, 2023 · 0 comments

Comments

@jlink
Copy link
Collaborator

jlink commented May 26, 2023

Testing Problem

It should be possible to create arbitraries from (a subset of) OpenJML specifications.

The most simple example (taken from https://www.openjml.org/examples/sum-max.html):

 //@ requires a.length > 0;
  void max(int[] a) {
    int sum = 0;
    int max = a[0];

    //@ loop_invariant 0 <= i <= a.length;
    //@ loop_invariant sum <= \count * max;  // Assertion to be proved
    for (int i=0; i<a.length; i++) {
      //@ assume Integer.MIN_VALUE <= sum + a[i] <= Integer.MAX_VALUE; // Just assume we never overflow
      sum += a[i];
      if (max < a[i]) max = a[i];
    }
  }

Referencing this method should enable jqwik to use Arbitraries.integers().toArray().withMinLength(1) for running properties on max(..).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant