()
| 2605 | /// an exit syscall, so the VM halts with that code. Built directly in IR. |
| 2606 | #[test] |
| 2607 | fn ir_trap_terminator_halts_with_code() { |
| 2608 | let mut entry = IrBlock::new("entry"); |
| 2609 | entry.set_terminator(IrTerminator::Trap { code: 134 }); |
| 2610 | |
| 2611 | let mut func = IrFunction::new("main", IrType::Integer(IntWidth::I32)); |
| 2612 | func.push_block(entry); |
| 2613 | let mut program = IrProgram::new("trap_direct"); |
| 2614 | program.push_function(func); |
| 2615 | |
| 2616 | let (_, outcome, _) = run_ir(&program); |
| 2617 | assert!( |
| 2618 | matches!(outcome, StepOutcome::Halted(134)), |
| 2619 | "a reached trap must halt with its diagnostic code; got {outcome:?}" |
| 2620 | ); |
| 2621 | } |
| 2622 | |
| 2623 | /// A `Trap` reached only on one branch arm fires only when that arm is taken; the |
| 2624 | /// other arm returns normally. Here the condition is false, so the trap is skipped. |
nothing calls this directly
no test coverage detected