| 1365 | } |
| 1366 | main: () -> i32 { |
| 1367 | result: i32 = sum_nine(1, 2, 3, 4, 5, 6, 7, 8, 9) |
| 1368 | if result == 45 { |
| 1369 | return 0 |
| 1370 | } |
| 1371 | return 1 |
| 1372 | } |
| 1373 | "#, |
| 1374 | ); |
| 1375 | assert!( |
| 1376 | matches!(outcome, RunOutcome::Halted(0)), |
| 1377 | "sum of 1..9 = 45 (9th arg via stack), got {outcome:?}" |
| 1378 | ); |
| 1379 | } |
| 1380 | |
| 1381 | /// Values held across a function call must be restored (callee-saved or spilled). |
| 1382 | #[test] |
| 1383 | fn call_callee_saves_preserved() { |
| 1384 | let (_, outcome, _) = run_hll( |
| 1385 | r#" |
| 1386 | compute: (x: i32, y: i32) -> i32 { |
| 1387 | return x + y |
| 1388 | } |