Open byorgey opened 2 years ago
Well, I actually thought of one benefit of attaching tests to definitions: it makes it easy to see which definition is wrong.
However, perhaps we could get the same benefit by simply noting (syntactically) which local definitions are mentioned in the definition of property, and mentioning them in the message for a failed test case.
Another benefit is that when trying to fill in definitions to make tests pass, it's easy to see which ones you've gotten right. But perhaps we could get this benefit by the ability to label tests somehow. Labelled tests could be displayed individually with their label. Maybe identically labelled tests would be grouped together. Unlabelled tests would all just be grouped together; essentially "no label" would be a special kind of label. As for syntax, the tricky part is to pick some label syntax that could easily be distinguished from an expression. e.g. [label] property
is out because it looks like a list. Maybe something like this?
!!! exp -- unlabelled
!!! label # exp -- labelled
Or what if whitespace after !!!
and before the property is required, and labels look like this:
!!![label] exp
For documentation purposes, educational purposes, etc., it may often make sense to put tests after a definition. However, at the moment this is impossible since we attach all tests to the following definition.
One alternative would be to forget the whole idea of attaching specific tests to specific functions. Maybe instead of something like
we could instead print something like
Another alternative would be to create some kind of syntax for specifying which definition a test should be attached to.
I kind of lean towards the first alternative at this point. I can't think of any particularly important benefits of attaching tests to definitions. And I can think of several situations in which the choice of which definition to attach a test to is arbitrary (for example, when expressing the property that two functions are inverses).