()
| 925 | ); |
| 926 | } |
| 927 | |
| 928 | // --- Helper --- |
| 929 | |
| 930 | fn ri(i: RealInstruction) -> RvInstruction { |
| 931 | RvInstruction::Real(i) |
| 932 | } |
| 933 | |
| 934 | // Returns the VM itself so a caller can peek at registers after the run. |
| 935 | fn assemble_and_run(insns: Vec<RvInstruction>) -> (VirtualMachine, StepOutcome) { |
| 936 | let assembled = Assembler::assemble(&insns).expect("assembly failed"); |
| 937 | let mut vm = VirtualMachine::new(&assembled); |
| 938 | let result = vm.run(100_000); |
| 939 | (vm, result.outcome) |
| 940 | } |
| 941 | |
| 942 | // --- Tests --- |
| 943 | |
| 944 | #[test] |
| 945 | fn test_exit_zero() { |
| 946 | let (_, outcome) = assemble_and_run(vec![ |
| 947 | ri(RealInstruction::Addi(Addi::new(10, 0, 0))), // a0 = 0 |
nothing calls this directly
no test coverage detected