Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document testable #319

Open
martindemello opened this issue Aug 21, 2021 · 5 comments
Open

document testable #319

martindemello opened this issue Aug 21, 2021 · 5 comments

Comments

@martindemello
Copy link

I found out about adding new testable types from this blogpost; there is nothing in the project docs about it.

@craigfe
Copy link
Member

craigfe commented Aug 22, 2021

Hi @martindemello,

By "the project docs", do you mean the README in this repository? The generated docs at http://mirage.github.io/alcotest/alcotest/Alcotest/ do reference the Alcotest.testable helper function for building testable values, as well as the implementation of the Alcotest.testable type (which is concrete, so can be constructed directly).

@martindemello
Copy link
Author

yeah, i meant the README and the examples. i didn't see the generated docs because they are also not linked to from the README :) but the package was easy enough to get up to speed with once i got the basic idea; i'll try to contribute some more docs once i've used it for a bit.

@craigfe
Copy link
Member

craigfe commented Aug 22, 2021

yeah, i meant the README and the examples. i didn't see the generated docs because they are also not linked to from the README :)

Good point! They are linked from a little docs badge, but it's not very visible – hopefully #320 will improve that.

i'll try to contribute some more docs once i've used it for a bit.

Thanks!

@mjambon
Copy link
Contributor

mjambon commented Sep 7, 2023

The approach using a first-class module of type TESTABLE requires a lot of mental gymnastics to simply provide a pair to_string/of_string to_string/equal. Please include an example in the API docs.

@mjambon
Copy link
Contributor

mjambon commented Sep 7, 2023

Here's an example for a fictitious module Fizz providing a to_string function and an equal function with the obvious types:

let fizz = Alcotest.testable (Fmt.of_to_string Fizz.to_string) Fizz.equal
...
let test_something () =
  Alcotest.check fizz "equal" Fizz.zero (Fizz.of_string "0")

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

No branches or pull requests

3 participants