diff --git a/dust-lang/src/vm/mod.rs b/dust-lang/src/vm/mod.rs index c98ff5e..0c58928 100644 --- a/dust-lang/src/vm/mod.rs +++ b/dust-lang/src/vm/mod.rs @@ -249,49 +249,3 @@ impl Display for Pointer { } } } - -#[cfg(test)] -mod tests { - use runner::{RunnerLogic, RUNNER_LOGIC_TABLE}; - - use super::*; - - const ALL_OPERATIONS: [(Operation, RunnerLogic); 24] = [ - (Operation::MOVE, runner::r#move), - (Operation::CLOSE, runner::close), - (Operation::LOAD_BOOLEAN, runner::load_boolean), - (Operation::LOAD_CONSTANT, runner::load_constant), - (Operation::LOAD_LIST, runner::load_list), - (Operation::LOAD_SELF, runner::load_self), - (Operation::GET_LOCAL, runner::get_local), - (Operation::SET_LOCAL, runner::set_local), - (Operation::ADD, runner::add), - (Operation::SUBTRACT, runner::subtract), - (Operation::MULTIPLY, runner::multiply), - (Operation::DIVIDE, runner::divide), - (Operation::MODULO, runner::modulo), - (Operation::TEST, runner::test), - (Operation::TEST_SET, runner::test_set), - (Operation::EQUAL, runner::equal), - (Operation::LESS, runner::less), - (Operation::LESS_EQUAL, runner::less_equal), - (Operation::NEGATE, runner::negate), - (Operation::NOT, runner::not), - (Operation::CALL, runner::call), - (Operation::CALL_NATIVE, runner::call_native), - (Operation::JUMP, runner::jump), - (Operation::RETURN, runner::r#return), - ]; - - #[test] - fn operations_map_to_the_correct_runner() { - for (operation, expected_runner) in ALL_OPERATIONS { - let actual_runner = RUNNER_LOGIC_TABLE[operation.0 as usize]; - - assert_eq!( - expected_runner, actual_runner, - "{operation} runner is incorrect" - ); - } - } -} diff --git a/dust-lang/src/vm/runner.rs b/dust-lang/src/vm/runner.rs index 89b75d5..49332f6 100644 --- a/dust-lang/src/vm/runner.rs +++ b/dust-lang/src/vm/runner.rs @@ -633,3 +633,50 @@ pub fn r#return(vm: &mut Vm, instruction_data: InstructionData) { panic!("Stack underflow"); } } + +#[cfg(test)] +mod tests { + + use crate::Operation; + + use super::*; + + const ALL_OPERATIONS: [(Operation, RunnerLogic); 24] = [ + (Operation::MOVE, r#move), + (Operation::CLOSE, close), + (Operation::LOAD_BOOLEAN, load_boolean), + (Operation::LOAD_CONSTANT, load_constant), + (Operation::LOAD_LIST, load_list), + (Operation::LOAD_SELF, load_self), + (Operation::GET_LOCAL, get_local), + (Operation::SET_LOCAL, set_local), + (Operation::ADD, add), + (Operation::SUBTRACT, subtract), + (Operation::MULTIPLY, multiply), + (Operation::DIVIDE, divide), + (Operation::MODULO, modulo), + (Operation::TEST, test), + (Operation::TEST_SET, test_set), + (Operation::EQUAL, equal), + (Operation::LESS, less), + (Operation::LESS_EQUAL, less_equal), + (Operation::NEGATE, negate), + (Operation::NOT, not), + (Operation::CALL, call), + (Operation::CALL_NATIVE, call_native), + (Operation::JUMP, jump), + (Operation::RETURN, r#return), + ]; + + #[test] + fn operations_map_to_the_correct_runner() { + for (operation, expected_runner) in ALL_OPERATIONS { + let actual_runner = RUNNER_LOGIC_TABLE[operation.0 as usize]; + + assert_eq!( + expected_runner, actual_runner, + "{operation} runner is incorrect" + ); + } + } +}