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 let (base_outcome, base_uart, base_lines, base_cycles) = run_with_regalloc(src, false);
68 let (alloc_outcome, alloc_uart, alloc_lines, alloc_cycles) = run_with_regalloc(src, true);
69 assert!(
70 matches!(base_outcome, RunOutcome::Halted(_)),
71 "baseline did not finish: {base_outcome:?}"
72 );
73 assert_eq!(
74 format!("{base_outcome:?}"),
75 format!("{alloc_outcome:?}"),
76 "register allocation changed the exit outcome"
77 );
78 assert_eq!(
79 base_uart, alloc_uart,
80 "register allocation changed UART output"
81 );
82 ((base_lines, base_cycles), (alloc_lines, alloc_cycles))
83}
84
85#[test]
86fn regalloc_arithmetic_branches_and_loops() {
87 let ((base_lines, base_cycles), (alloc_lines, alloc_cycles)) = assert_equivalent(
88 r#"
89compute: (n: i64) -> i64 {

Calls 1

run_with_regallocFunction · 0.85