diff --git a/src/simulator/machine.rs b/src/simulator/machine.rs index c9c1877..cf6c659 100644 --- a/src/simulator/machine.rs +++ b/src/simulator/machine.rs @@ -638,7 +638,8 @@ mod test { mem_cmp::MemChecker::fill_memory_from_mem_checker(&memory_before, &mut m); Machine::run(&mut m); let expected_trace = fs::read_to_string(get_full_path!("reg_trace", $a)).unwrap(); - (m, memory_after, expected_trace) + assert!(mem_cmp::MemChecker::compare_machine_memory(&memory_after, &m)); + assert!(expected_trace.contains(m.registers_trace.as_str())); }}; } @@ -670,64 +671,46 @@ mod test { #[test] fn test_comp() { - let (m, memory_after, expected_trace) = init_test!("Comp"); - assert!(mem_cmp::MemChecker::compare_machine_memory(&memory_after, &m)); - assert!(expected_trace.contains(m.registers_trace.as_str())); + init_test!("Comp") } #[test] fn test_add() { - let (m, memory_after, expected_trace) = init_test!("Add"); - assert!(mem_cmp::MemChecker::compare_machine_memory(&memory_after, &m)); - assert!(expected_trace.contains(m.registers_trace.as_str())); + init_test!("Add") } #[test] fn test_div() { - let (m, memory_after, expected_trace) = init_test!("Div"); - assert!(mem_cmp::MemChecker::compare_machine_memory(&memory_after, &m)); - assert!(expected_trace.contains(m.registers_trace.as_str())); + init_test!("Div") } #[test] fn test_if() { - let (m, memory_after, expected_trace) = init_test!("If"); - assert!(mem_cmp::MemChecker::compare_machine_memory(&memory_after, &m)); - assert!(expected_trace.contains(m.registers_trace.as_str())); + init_test!("If") } #[test] fn test_jump() { - let (m, memory_after, expected_trace) = init_test!("Jump"); - assert!(mem_cmp::MemChecker::compare_machine_memory(&memory_after, &m)); - assert!(expected_trace.contains(m.registers_trace.as_str())); + init_test!("Jump") } #[test] fn test_mul() { - let (m, memory_after, expected_trace) = init_test!("Mult"); - assert!(mem_cmp::MemChecker::compare_machine_memory(&memory_after, &m)); - assert!(expected_trace.contains(m.registers_trace.as_str())); + init_test!("Mult") } #[test] fn test_ret() { - let (m, memory_after, expected_trace) = init_test!("Ret"); - assert!(mem_cmp::MemChecker::compare_machine_memory(&memory_after, &m)); - assert!(expected_trace.contains(m.registers_trace.as_str())); + init_test!("Ret") } #[test] fn test_sub() { - let (m, memory_after, expected_trace) = init_test!("Sub"); - assert!(mem_cmp::MemChecker::compare_machine_memory(&memory_after, &m)); - assert!(expected_trace.contains(m.registers_trace.as_str())); + init_test!("Sub") } #[test] fn test_switch() { - let (m, memory_after, expected_trace) = init_test!("Switch"); - assert!(mem_cmp::MemChecker::compare_machine_memory(&memory_after, &m)); - assert!(expected_trace.contains(m.registers_trace.as_str())); + init_test!("Switch") } }