MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / ir_trap_terminator_halts_with_code

Function ir_trap_terminator_halts_with_code

tests/integration/vm_execution.rs:2607–2621  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2605/// an exit syscall, so the VM halts with that code. Built directly in IR.
2606#[test]
2607fn 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.

Callers

nothing calls this directly

Calls 4

run_irFunction · 0.85
push_blockMethod · 0.80
push_functionMethod · 0.80
set_terminatorMethod · 0.45

Tested by

no test coverage detected