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

Some shrinkers are incomplete #36

Closed
Gbury opened this issue May 31, 2017 · 1 comment
Closed

Some shrinkers are incomplete #36

Gbury opened this issue May 31, 2017 · 1 comment

Comments

@Gbury
Copy link
Collaborator

Gbury commented May 31, 2017

Some shrinkers only try a few possibles values: for instance the default shrinker for integers try to divide the integer by 2, but if that fails, it doesn't try further. One example of problematic behavior is the following:

let test =
  QCheck.Test.make ~count:1000 ~name:"mod3"
   QCheck.int (fun i -> i mod 3 <> 0);;

which results in:

QCheck_runner.run_tests [test];;
random seed: 275954313
--- Failure --------------------------------------------------------------------
Test mod3 failed (0 shrink steps):

-4393318161250674747
================================================================================
failure (1 tests failed, 0 tests errored, ran 1 tests)

giving a very non-minimal counter-example, instead of the obvious 0, because shrinking failed at the first step.

I think shrinkers should always cover the totality of smaller values, using a 'smart' ordering, much like what is done in the case of lists and arrays (where all sub-lists are tried). So I think the integer shrinker (and possibly others) should probably be fixed, unless there is a compelling argument not to do it ?

@c-cube
Copy link
Owner

c-cube commented May 31, 2017

Quite reasonable indeed.

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