Stream: ideas

Topic: Testing for Errors


view this post on Zulip Luke Boswell (Dec 07 2022 at 04:38):

Instead of doing this and hardcoding the string

expect parsePartial (chompUntil '\n') [] == Err (ParsingFailure "character not found")

Maybe we could permit this? Or is there a better way?

expect parsePartial (chompUntil '\n') [] == Err (ParsingFailure _)

view this post on Zulip Luke Boswell (Dec 07 2022 at 04:42):

FYI I got this to work, but it's not really clear what it does I think.

expect when parsePartial (chompUntil '\n') [] is
    Ok _ -> Bool.false
    Err (ParsingFailure _) -> Bool.true

view this post on Zulip Brendan Hansknecht (Dec 07 2022 at 04:44):

I guess you really want something like this:

expect parsePartial (chompUntil '\n') [] |> isParsingFailure

?

view this post on Zulip Brendan Hansknecht (Dec 07 2022 at 04:45):

Where you can somehow check the tag of a union in a lightweight manner that is less verbose?

view this post on Zulip Brendan Hansknecht (Dec 07 2022 at 04:45):

Though I guess it is nested, so that is more complex

view this post on Zulip Luke Boswell (Dec 07 2022 at 05:06):

I think your right, a helper will make more sense. I don't think what I suggested even makes sense looking at it closer...


Last updated: Jun 16 2026 at 16:19 UTC