How hard would it be to do effectively the same thing as rust's pretty_assertions library, but with Roc's expect. I'm currently running this - and it'd be _really_ nice if I could get a diff of what's wrong:
── EXPECT FAILED ─────────────────────────────────────────────── generator.roc ─
This expectation failed:
150│> expect (render (Items [Text "{", Indent (Line (Text "foo")), Text "}"])) ==
151│> """
152│> {
153│> foo
154│> }
155│> """
if you bind both sides of the expect to a variable then at least it'll print out the value
assuming this is toplevel, that would be
expect
x = (render (Items [Text "{", Indent (Line (Text "foo")), Text "}"]))
expect x ==
"""
{
foo
}
"""
Aha, yep, that works (minus the extra expect on line 4)
FWIW, I tried this:
expect
dbg (render (Line (Text "foo")))
1 == 1
... which then hits unreachable code:
thread '<unnamed>' panicked at 'internal error: entered unreachable code: I think this is unreachable', crates/compiler/mono/src/ir.rs:4503:23
yeah there's a lot of room for improvement here! I'd like to eventually get into things like nicer diffs, but I think short-term the bigger deal is fixing bugs around expect and dbg :big_smile:
Last updated: Jun 16 2026 at 16:19 UTC