Skip to content

Testing macro for BIF #27

Description

@RyanSiu1995

I think we can trim the testing code with a macro for calling the bif function.
During my development, the following codes were repeatedly entered.

let vm = vm::Machine::new();
let module: *const module::Module = std::ptr::null();
let process = process::allocate(&vm.state, module).wrap();
let args = vec![xxxxxxx];
let res = bif_the_function_I_want_to_test(&vm, &process, &args);

Most of the codes are not used for testing. The code duplication is so high that I think it can be replaced by a macro as a high order function like the following one.

macro_rules! test_it(func: func ; $($arg: expr), *) => {
  // The code as the above
}

I can do this in Elixir but not sure if it is valid in Rust.
Does it sound a valid solution to you? @archseer
If it is okay, I will do it and refactor the unit tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions