Is there a way to e.g. assertMatch, but such that matched variables become binded?
assertMatch
Example:
?assertMatch({ok, Result1}, some:fun()), foo:bar(Result1)
I’d like to avoid matching patterns twice, but would still like to use asserts over plain matching. Any ideas?
I wished all assert macros would return the value of the matched expression (or that the would magically bind it internally, but not sure about the implications of that…).
One always ends up writing tons of test code like this:
Result1 = make_request(), ?asserMatch({ok, 200, _Body}, Result), {ok, _Code, Body} = Result % …
Not sure if ?assetMatch(…) catches exceptions and fails the asset, because if so that is also broken with the above approach.
?assetMatch(…)