TestHelper.TestMacro (Anoma v0.29.0)
I am a module populated by macros associated to Anoma Testing.
My use macro replaces ExUnit.case use macro with the caveat of ignoring the Assertions imports.
Use me in order to define various macros to be used in tests.
Summary
Functions
I call the assert
macro from ExUnit.Assertions
I call the assert_receive
macro from ExUnit.Assertions
I catch a variable binding expression in debug mode and call call_assert
on it.
I add the ExUnit.Assertions prefix to the function call on the AST level and apply it to the expression as a quoted structure.
I call the try functionality to capture the error.
Depending on the given message, I call either assert
or refute
with
different arities.
I quote the error-capturing of expressions.
I call the refute
macro from ExUnit.Assertions
I call the assert_refute
macro from ExUnit.Assertions
I present a quoted expression to try depending on the input.
Functions
I call the assert
macro from ExUnit.Assertions
If the environment is :debug I pry on errors.
I call the assert_receive
macro from ExUnit.Assertions
If the environment is :debug I pry on errors.
assertion_abstract(arg1, atom, expr)
@spec assertion_abstract(atom(), atom(), Macro.input()) :: Macro.input()
I catch a variable binding expression in debug mode and call call_assert
on it.
If the expression caught is variable-bining, after evaluating I also call said binding at AST level to bind it outside try-rescue.
If the expression is not in debug mode, I simply call the assertion on the expression.
assertion_alias(atom, expr)
@spec assertion_alias(atom(), Macro.input()) :: Macro.input()
I add the ExUnit.Assertions prefix to the function call on the AST level and apply it to the expression as a quoted structure.
call_assert(atom, expr)
@spec call_assert(atom(), Macro.input()) :: Macro.input()
I call the try functionality to capture the error.
Pattern-Matching Variations
call_assert(atom, [{:=, _, [left, _]}])
- Afterwards I bind theleft side variables.
call_assert(atom, expr)
- Just call the capture.
message_parse(expr, atom, msg)
@spec message_parse(Macro.input(), atom(), String.t() | nil) :: Macro.input()
Depending on the given message, I call either assert
or refute
with
different arities.
quote_try(atom, expr)
@spec quote_try(atom(), Macro.input()) :: Macro.input()
I quote the error-capturing of expressions.
I call the refute
macro from ExUnit.Assertions
If the environment is :debug I pry on errors.
I call the assert_refute
macro from ExUnit.Assertions
If the environment is :debug I pry on errors.
try_assert(atom, expr)
@spec try_assert(atom(), Macro.input()) :: Macro.input()
I present a quoted expression to try depending on the input.
Pattern-Matching Variations
try_assert(atom, [{:=, _, _}])
- I use the assertion, print thebinded variables to escape warnings and then print the original result
try_assert(atom, expr)
- I use the assertion