c-cube / qcheck

QuickCheck inspired property-based testing for OCaml.
https://c-cube.github.io/qcheck/
BSD 2-Clause "Simplified" License
345 stars 37 forks source link

Regression: Revert shrinker fix #280

Closed jmid closed 1 year ago

jmid commented 1 year ago

I was too eager optimizing the list shrinker in #277 where the optimization of the 2-element case in the below code

  let rec list_spine l yield =
    let rec split l len acc = ... in
    match l with
    | [] -> ()
    | [_] -> yield []
    | [x;y] -> yield []; yield [x]; if x <> y then yield [y]
    | ...

may raise an exception if the list happens to contain function values:

# QCheck.Shrink.list_spine [pred;succ] ignore;;
Exception: Invalid_argument "compare: functional value".

This just bit me in qcheck-lin, so this PR

Afterwards I plan to roll a 0.21.1 bugfix release.