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

nat_split2 and pos_split2 are reversed #180

Closed
just-max opened this issue Sep 14, 2021 · 1 comment
Closed

nat_split2 and pos_split2 are reversed #180

just-max opened this issue Sep 14, 2021 · 1 comment

Comments

@just-max
Copy link

(documentation snippets are from https://c-cube.github.io/qcheck/0.18/qcheck-core/QCheck/Gen/index.html)
Expected behaviour: generators with "nat" in their names should generate non-negative natural numbers, generators with "pos" should generate strictly positive natural numbers.

The documentation agrees:

  • val nat_split2 : int -> (int * int) t : ... generates pairs (n1, n2) of natural numbers ...
  • val pos_split2 : int -> (int * int) t : ... generates pairs (n1, n2) of strictly positive (nonzero) natural numbers ...

What actually happens:

  • nat_split2 cannot generate zeroes, even though it should (ie. QCheck.Gen.(generate (nat_split2 2)) only generates pairs (1, 1))
  • pos_split2 can and does generate zeroes, even though it shouldn't (ie. QCheck.Gen.(generate (pos_split2 0)) does not cause errors and generates pairs (0, 0))
  • The documentation for nat_split2 also states the restriction "raises Invalid_argument unless n >= 2" which should really apply to pos_split2.
  • The documentation for pos_split2 refers to nat_split2 (... "nat_split2 n generates pairs")

Although it should probably be a separate issue, the counterparts generalized to lists, nat_split and pos_split, don't seem to work at all (regardless if the precondition n <= k is satisfied).

@gasche
Copy link
Contributor

gasche commented Sep 22, 2021

I am probably responsible for the mistakes (I proposed nat_split and pos_split in #114), I'll have a look.

gasche added a commit to gasche/qcheck that referenced this issue Sep 22, 2021
@jmid jmid mentioned this issue Nov 2, 2021
@jmid jmid closed this as completed in 906af37 Dec 2, 2021
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