macro_rules! test_suite {
    ( state($state: ty), options $options: tt, expansion_equality_tests ( $( ($name: ident, $lhs: expr, $rhs: expr $(,)? ) ),* $(,)? ) $(,)? ) => { ... };
    ( state($state: ty), options $options: tt, expansion_equality_tests $test_body: tt $(,)? ) => { ... };
    ( state($state: ty), options $options: tt, serde_tests ( $( ($name: ident, $lhs: expr, $rhs: expr $(,)? ) ),* $(,)? ) $(,)? ) => { ... };
    ( state($state: ty), options $options: tt, failure_tests ( $( ($name: ident, $input: expr $(,)? ) ),* $(,)? ) $(,)? ) => { ... };
    ( state($state: ty), options $options: tt, $test_kind: ident $test_cases: tt $(,)? ) => { ... };
    ( state($state: ty), options $options: tt, $( $test_kind: ident $test_cases: tt ),+ $(,)? ) => { ... };
    ( options $options: tt, $( $test_kind: ident $test_cases: tt ),+ $(,)? ) => { ... };
    ( $( $test_kind: ident $test_cases: tt ),+ $(,)? ) => { ... };
}
Expand description

Macro to generate a suite of unit tests

The general use of this macros looks like this:

test_suite![
    state(State),
    options(TestOptions::InitialCommands(initial_commands)),
    expansion_equality_tests(
        (case_1, "lhs_1", "rhs_1"),
        (case_2, "lhs_2", "rhs_2"),
    ),
    failure_tests(
        (case_3, "input_3"),
        (case_4, "input_4"),
    ),
];

The arguments to the macro are:

  • state(State): defines which Rust type to use as the VM state in the tests. This can be omitted, in which case it defaults to the type name State in the current scope.

  • options(option_1, option_2, ..., option_n): options to pass to the test runner. This is a list of values of type TestOption. The options can be omitted, in which case they default to options(TestOptions::InitialCommands(initial_commands)). In this case initial_commands is a static function that returns a list of built-in primitives to initialize the VM with.

  • expansion_equality_tests(cases...): a list of expansion equality test cases. Each case is of the form (case name, left hand side, right hand side). The data here is fed into the run_expansion_equality_test test runner.

  • failure_tests(cases...): a list of failure test cases. Each case is of the form (case name, input). The data here is fed into the run_failure_test test runner.

Only one state() argument may be provided, and if provided it must be in the first position. Only one options() argument may be provided, and if provided it must be in the first position or after the state() argument. Zero or more of the other arguments may be provided, and in any order.