Hi,

On Fri, Mar 16, 2018 at 7:12 AM, Bahman Movaqar <bahman@bahmanm.com> wrote:
[...]
Suppose that I wrote this piece of code as a library to be used by others as well. In such a case, practically the only function that the users are interested in is `solve`, as defined in the .mli file.
This is good: keeps my library clean, the usage straight-forward and doesn't confuse the users.

However, when it comes to testing, things are not that simple. Now that I have exported only 1 function in the .mli, I can only test that 1 function.
Is this the proper way[2]?

This is a rather philosophical question. Some people like to test only the exposed interface, because that's the only thing that's relevant to users. The internal functionality should be there only to support the external-facing interface, and thus testing the `solve` function thoroughly should automatically test all internal functionality. If it doesn't, then maybe that internal functionality shouldn't be there in the first place?

But, maybe sometimes you do want to have some internal functionality and you do want to test it. An OCaml can theoretically some of its files (modules) from the outside world by telling its build system to not expose the compiled interface (.cmi) files. This way, you can write and test these internal modules and still hide them from users.

I haven't actually usec this technique, but certainly someone in this list might have.

Regards,

Yawar