Hello! I work at Antithesis, a deterministic simulation testing startup.
Recently, we released Hegel for OCaml.
Hegel is a family of PBT libraries based on Hypothesis, providing powerful, ergonomic property-based testing for many different languages. Hegel lets you declare data generation inline with your test code, and provides native support for stateful testing.
The installation instructions can be found at the Github repository here. Click on the link in the about section in the repository to see the documentation (sorry, I can’t post more than two links yet). We encourage people to contribute!
Here’s an example Hegel test:
let bad_map _ xs = xs
let%hegel_test bad_map_vs_map tc =
let int_gen = integers () in
let int_fn_gen = functions ~sexp_of_arg:Core.Int.sexp_of_t ~returns:int_gen () in
let f = draw_silent tc int_fn_gen
and xs = draw tc (lists int_gen ()) in
require_equal
tc
(Core.List.sexp_of_t Core.Int.sexp_of_t)
(bad_map f xs) (List.map f xs)
prints (with colors in the terminal):
--- Failure: bad_map_vs_map (examples/higher_order.ml:20) --------------
Falsified after 2 test cases (0 discarded):
xs = (0)
f 0 = 1
require_equal: values differ (- lhs / + rhs):
(0) (1)
Exception: Failure("require_equal: values differ")
rerun with: [@@failure_blobs [ "AAQAAAABAQAKAQAAAAABAAAKAQAAAAE=" ]]
Happy testing!
