roc
roc copied to clipboard
`expect` not printing mentioned variables
To reproduce, run this (either at the top level with roc test or inline with roc dev - both reproduce it):
x = 5
expect x != x
42
It prints a failed expectation, but doesn't show the value of x.
We should make a test case for this!
F# has a library for this: https://github.com/SwensenSoftware/unquote It works in two ways:
- providing custom operators like
=!,>!, etc., e.g.5 >! 4(meaning 5 should be greater than 4) - or utilizing special expressions like
<@ 5 > 2+2 @>(it evaluates the expression and in case of failure inspects and reduces the expression within)
[<Fact>]
let ``demo Unquote xUnit support`` () =
test <@ [3; 2; 1; 0] |> List.map ((+) 1) = [1 + 3..1 + 0] @>
Test 'Module.demo Unquote xUnit support' failed:
[3; 2; 1; 0] |> List.map ((+) 1) = [1 + 3..1 + 0]
[4; 3; 2; 1] = [4..1]
[4; 3; 2; 1] = []
false
So it does reduce the expression step by step.
I am not sure how this could map to Roc, but I thought it might be of interest to whoever tries to solve the issue.