vincent-hugot / qtest

Inline (Unit) Tests for OCaml
GNU General Public License v3.0
67 stars 8 forks source link

Automatic equality #40

Closed copy closed 8 years ago

copy commented 8 years ago

This is just an idea: The need to specify equality tests separately could be removed by bringing a special (=) into the scope of the test case which remembers its arguments, similar to this:

let (=) a b = __last_eq := Some (a, b); a = b

Then, this idea can be extended to other comparison operators and possibly also custom equality. It's an ugly hack, but it makes tests cleaner, easier to write and allows mixing equality and normal tests in a test block.

c-cube commented 8 years ago

This would be nice in principle, but I don't think it works, as __last_eq would have the type 'a ref which is forbidden in OCaml. I'm not really in favor of such dark magic ^^.

If you think it does work, feel free to re-open!