Is there a way to do property based testing with expect
at this time?
Nope.
Brendan has done a lot of work investigating this. Here is a previous post with some links.
you can do a weak form of it at the moment, where you hardcode a seed and randomly generate things
makes sense
I would definitely like to be awesome at it in the future, though!
yeah, totally. i think unison is a cool example of supporting “inline-ish” property based testing
of course unison has some unique characteristics too
I'm not familiar with what Unison does on that! How does it work?
one sec
https://www.unison-lang.org/docs/usage-topics/testing/ is a good read
Do we have enough of a starting point that we could make an Issue for roc fuzz
that if someone was interested might be able to pickup and do some research?
My thoughts is how can we capture the general intention to explore fuzzing and one day include it in roc. It may also be a cool project someone might want to contribute and learn more about the science and engineering behind fuzzing testing.
codebases in unison are like small talk images (i think), so i’m not sure how much some of the choices apply to roc
I think in practice we should make a property based testing framework for the simplicity and minimal dependencies. Long term, we should ensure that it can also be used with a fuzz engine for more comprehensive testing. Whether long term we follow in Go's footsteps and have an integrated fuzz engine to fix the dependency problems or make it easy for an external fuzz engine to hook in is still very much open for design. But for simple unit testing, a basic property based testing framework would be huge. Some like hypothesis in python.
oh I think we can make it all builtin
including things like automatically deriving Arb
the way we do for encoders and decoders etc.
@Brendan Hansknecht what do you mean by "framework". We don't normally talk about these in roc. Is this a user space roc package? or a specific platform?
sorry, bad wording on my part. I think it should be built into the compiler and into expect
. We should have an Arbitrary
implementation that would start simple and for raw PBT only, but would be open to tying into a fuzzing harness.
Last updated: Jul 06 2025 at 12:14 UTC