Stream: ideas

Topic: Grouping multiple `expect` assertions


view this post on Zulip Ryan Bates (Dec 20 2023 at 18:44):

Sometimes I want to check multiple values in an expect call. Usually this happens when I have a complex record where I want to assert a few attributes.

expect
    result = parse "some complex string that I need to parse"
    result.name == "a" && result.values == [1, 2, 3] && result.direction == North

Imagine there's a 4th attribute here I don't want to test so I can't do == { ... }.

Doing && here is fine, but it gets cumbersome if I add more assertions. I could split this up into multiple expect calls but then duplicating the test setup can get verbose.

What I'd like is a way to group test code and use expect for each assertion. Perhaps with a test keyword.

test
    result = parse "some complex string that I need to parse"
    expect result.name == "a"
    expect result.values == [1, 2, 3]
    expect result.direction == North

Thoughts?


Last updated: Jun 16 2026 at 16:19 UTC