art-w / sherlodoc

Fuzzy type search for OCaml documentation
MIT License
72 stars 6 forks source link

Unit test type distance #39

Open EmileTrotignon opened 9 months ago

EmileTrotignon commented 9 months ago

The query/type_distance.ml does complicated things that should be unit tested.

The unit test framework is alcotest. You can file examples of its uses in query/test, which is also the directory where you should write the new tests.

To test this, you should write by hand a few values of Db.Typexpr.t, compute their distance and write the value you get as the expected value.

Some of the types tested should be similar, so that the distance is small, because the type distance function is going to be used on similar types.

You should also test that the distance of a type with itself is 0.

You can also use Query.Private.Type_parser.of_string to get types from strings, instead of writing them as ocaml values.