by tobyhinloopen · 3y ago · 0 comments
IE
a = 1; b = 2
assert a == b
Will fail with error like: Assertion failed,
a == b
Left is 1
Right is 2
So you don’t have a bunch of assert-functions; you just assert anything and it will spit out a decent error.e.g. in pytest it won't just print out the values of "a" and "b", it will recursively document intermediate values until it's reached the toplevel expression:
assert f() == g()
assert 42 == 43
where 42 = <function TestFailing.test_simple.<locals>.f at 0xdeadbeef0002>()
and 43 = <function TestFailing.test_simple.<locals>.g at 0xdeadbeef0003>()
and it's possible to customise the report so you can report as a diff: assert "foo 1 bar" == "foo 2 bar"
- foo 2 bar
? ^
+ foo 1 bar
? ^In Ecstasy, we built the support directly into the compiler again:
val a = 1;
val b = 2;
assert a == b;
Produces: IllegalState: a == b, a=1, b=2