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

Function assert_equivalent

tests/integration/regalloc.rs:69–86  ·  view source on GitHub ↗

Assert the program behaves identically with allocation off and on, and return the (off, on) instruction counts and cycle counts for extra checks.

(src: &str)

Source from the content-addressed store, hash-verified

67// Asserts identical behaviour with allocation off and on, and returns the
68// (off, on) instruction and cycle counts for extra checks.
69fn assert_equivalent(src: &str) -> ((usize, u64), (usize, u64)) {
70 let (base_outcome, base_uart, base_lines, base_cycles) = run_with_regalloc(src, false);
71 let (alloc_outcome, alloc_uart, alloc_lines, alloc_cycles) = run_with_regalloc(src, true);
72 assert!(
73 matches!(base_outcome, StepOutcome::Halted(_)),
74 "baseline did not finish: {base_outcome:?}"
75 );
76 assert_eq!(
77 format!("{base_outcome:?}"),
78 format!("{alloc_outcome:?}"),
79 "register allocation changed the exit outcome"
80 );
81 assert_eq!(
82 base_uart, alloc_uart,
83 "register allocation changed UART output"
84 );
85 ((base_lines, base_cycles), (alloc_lines, alloc_cycles))
86}
87
88#[test]
89fn regalloc_arithmetic_branches_and_loops() {

Calls 1

run_with_regallocFunction · 0.85