Skip to content

Conversation

@jmid
Copy link
Contributor

@jmid jmid commented Jul 9, 2025

The forthcoming QCheck 0.26 release ocaml/opam-repository#28148 changes the distribution of the float generator to avoid blind spots: c-cube/qcheck#350

As a consequence, the existing round-trip property-based test for CBor now fails to hold, as nan = nan doesn't hold, resulting in, e.g.:

File "tests/core/dune", line 2, characters 7-8:
2 |  (name t)
           ^
seed: 9590b92181c82cc2
testing containers: running 1219 tests…
FAILED: (test :file 'tests/core/t_cbor.pp.ml' :n 0)
1219 tests done in 4.880s
ERROR (1 failures)

========
failed (test :file 'tests/core/t_cbor.pp.ml' :n 0):
failed on instances:
  `{-nan: ""}` (after 25 shrink steps)
roundtrip failed: from {-nan: ""} to {-nan: ""}

This PR patches the round-trip property with a recursively defined equality predicate, falling back on Float.equal to compare nans (which has the desired behaviour).

@c-cube
Copy link
Owner

c-cube commented Jul 9, 2025

excellent catch! 😍 Thank you!

@c-cube c-cube merged commit 3b49ad2 into c-cube:main Jul 11, 2025
8 checks passed
@c-cube
Copy link
Owner

c-cube commented Jul 11, 2025

thank you :)

@jmid jmid deleted the cbor-roundtrip-prop-patch branch July 11, 2025 20:50
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

Successfully merging this pull request may close these issues.

2 participants