TestHelper.TestMacro (Anoma v0.25.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

Link to this macro

assert(expr, msg \\ nil)

(macro)

I call the assert macro from ExUnit.Assertions

If the environment is :debug I pry on errors.

Link to this macro

assert_receive(expr, timeout \\ nil, failure_message \\ nil)

(macro)

I call the assert_receive macro from ExUnit.Assertions

If the environment is :debug I pry on errors.

Link to this function

assertion_abstract(arg1, atom, expr)

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.

Link to this function

assertion_alias(atom, expr)

I add the ExUnit.Assertions prefix to the function call on the AST level and apply it to the expression as a quoted structure.

Link to this function

call_assert(atom, expr)

I call the try functionality to capture the error.

Pattern-Matching Variations

  • call_assert(atom, [{:=, _, [left, _]}]) - Afterwards I bind the
                                            left side variables.
  • call_assert(atom, expr) - Just call the capture.
Link to this function

message_parse(expr, atom, msg)

Depending on the given message, I call either assert or refute with different arities.

Link to this function

quote_try(atom, expr)

I quote the error-capturing of expressions.

Link to this macro

refute(expr, msg \\ nil)

(macro)

I call the refute macro from ExUnit.Assertions

If the environment is :debug I pry on errors.

Link to this macro

refute_receive(expr, timeout \\ nil, failure_message \\ nil)

(macro)

I call the assert_refute macro from ExUnit.Assertions

If the environment is :debug I pry on errors.

Link to this function

try_assert(atom, expr)

I present a quoted expression to try depending on the input.

Pattern-Matching Variations

  • try_assert(atom, [{:=, _, _}]) - I use the assertion, print the
                                   binded variables to escape
                                   warnings and then print the
                                   original result
  • try_assert(atom, expr) - I use the assertion