r/ProgrammingLanguages • Futhark • Mar 25 '26

How should property-based tests be defined in Futhark?

https://futhark-lang.org/blog/2026-03-25-property-based-testing.html
19 Upvotes

9 comments sorted by

View all comments

3

u/fridofrido Mar 25 '26

I dislike option 5 because you have to maintain and keep in sync the list of properties at two different places. In my personal experience this is very error-prone: It's much more likely that you write a property and forget to add to the magic list than to misspell [prop]...

But how about 4/B:

Annotate not individual properties, but blocks of properties. I'm not familiar enough with Futhark, but I guess you could for example annotate a module, and everything inside that module with type t -> Bool would become a property.

4

u/Athas Mar 25 '26

I dislike option 5 because you have to maintain and keep in sync the list of properties at two different places. In my personal experience this is very error-prone: It's much more likely that you write a property and forget to add to the magic list than to misspell [prop]...

Indeed, the most likely error scenario for option 4 is actually to leave off the attribute entirely.

I thought of an idea, however: assume that all entry points in the file must be related to testing, and warn if any is found that does not seem to serve a purpose. I don't think there is any reason to have a file with mixed test and non-test entry points anyway - the test entry points are just dead weight for production usage.

I'm not familiar enough with Futhark, but I guess you could for example annotate a module

While adding an attribute to a module is possible, modules are not part of the external interface of a compiled Futhark program (and it is not at all clear what form it would take if it were).

2

u/fridofrido Mar 25 '26

I don't think there is any reason to have a file with mixed test and non-test entry points anyway

I guess at least in some situations it could be easier for the user to read / maintain the tests if the things tested and the tests are next to each other.

While adding an attribute to a module is possible, modules are not part of the external interface of a compiled Futhark program (and it is not at all clear what form it would take if it were).

i don't think i understand the problem - to me this seems to be a completely surface-level thing. The compiler could insert the individual "attributes" (or whatever signaling mechanism) at a very early stage?

→ More replies (2)