Stream: beginners

Topic: Non-pure tests


view this post on Zulip Nick Hallstrom (Mar 12 2023 at 02:57):

It seems like with the way expect works, it must always test pure code. What is the plan for testing non-pure code? I think I remember hearing something about mocking out Tasks at one point. That would make it so that the tests are effectively still pure. What if I need side effects in tests? For example, I was trying to think of how property-based testing would work since you’d need a way to generate randomness.

view this post on Zulip Brendan Hansknecht (Mar 12 2023 at 03:02):

I don't know the details of how it will work, but the plan is to have expect-fx for that

view this post on Zulip Brendan Hansknecht (Mar 12 2023 at 03:03):

Also, for property based tests, I would assume eventually if they are wanted, they would be built into the language test runner. That way it can control the randomness (that or maybe done somehow through expect-fx or similar.

view this post on Zulip Brendan Hansknecht (Mar 12 2023 at 03:04):

And yeah, with the changes to Tasks, it should be able to mock and test them in pure roc, theoretcially with expect

view this post on Zulip Nick Hallstrom (Mar 12 2023 at 03:06):

Ah I hadn’t heard about expect-fx, cool. Out of curiosity, are there any designs/examples of what mocking Tasks would look like?

view this post on Zulip Brendan Hansknecht (Mar 12 2023 at 03:08):

@Richard Feldman do you have a doc for this? The effect interpreter stuff that enables task mocking?

view this post on Zulip Richard Feldman (Mar 12 2023 at 03:36):

yeah I don't have an example yet unfortunately, it's still WIP


Last updated: Jul 06 2025 at 12:14 UTC