I've been using the following custom assertion checker in my test projects for quite some time:
val trap : Expr<'T> -> 'T
This evaluates the expression tree as normal, returning the result if successful but outputing the full evaluation metadata if exceptional. This can be quite useful for asserting preconditions during a test run, e.g.
Notice how trap gives me the confidence of performing unsafe lookups like .Value and .[42] since any failure will render as a nice assertion exception.
I've been using the following custom assertion checker in my test projects for quite some time:
This evaluates the expression tree as normal, returning the result if successful but outputing the full evaluation metadata if exceptional. This can be quite useful for asserting preconditions during a test run, e.g.
Notice how
trap
gives me the confidence of performing unsafe lookups like.Value
and.[42]
since any failure will render as a nice assertion exception.