alcotest icon indicating copy to clipboard operation
alcotest copied to clipboard

Consider comparison functions

Open cfcs opened this issue 7 years ago • 0 comments

Being able to check comparisons, and have pretty-printing for failed cases, would be nice - something like:

Alcotest.(check bool (greater_than int) ) "verify that y > x" true y x

I can do the check with boolean comparisons like this (below), but then I won't get the values of x,y:

Alcotest.(check bool bool) "verify that y > x" true (y > x)

This could either be solved by making Alcotest.TESTABLE require a compare instead of equal (which is already used by many other things, like Set and Map), but breaks backwards compatibility, or by supplying convenience functions besides check, which could use an optional ?compare, defaulting to polymorphic comparison, and wrapping the pp.

cfcs avatar Mar 19 '18 15:03 cfcs