Commit e683ab36 authored by Camil Staps's avatar Camil Staps 🚀

Document @property-test-generator

parent b091ff07
......@@ -86,6 +86,32 @@ blocks: comments above function types. This works as follows:
generated: one with `Int` and one with `Real`. When multiple type variables
are used, all combinations are tested.
- Sometimes, Gast's generic test generation method is not very useful. This is
for instance the case with types for which automatically generated values are
not 'valid'.
Take `Set a` as an example. It is possible to write tests on `[a]` instead,
then in every test use `fromList :: [a] -> Set a` to get the set. However,
this is not very modular, and also clutters up the properties.
What you can do instead is writing tests as you would normally do,
quantifying over `Set a` in the property signature, and then add a
`@property-test-generator` to the module. This field tells the test generator
how to generate values of a certain type. An example is:
* @property-test-generator [a] -> Set a | < a
* gen xs = fromList xs
Currently, only generators with arity 1 are supported (but this can be worked
around using a tuple or an auxiliary data type in the `@property-bootstrap`).
When the generator has class constraints, you are expected to resolve them
yourself by providing the required instances, depending on the type variable
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment