| 2449 | "expected Halted(3), got {outcome:?}" |
| 2450 | ); |
| 2451 | } |
| 2452 | |
| 2453 | #[test] |
| 2454 | fn float_int_to_float_roundtrip() { |
| 2455 | // i32 -> f64 (fcvt.d.w) then f64 -> i32 (fcvt.w.d). Before the fix both |
| 2456 | // casts were a plain `mv` reinterpreting the bit pattern. |
| 2457 | let (_, outcome, _) = run_hll( |
| 2458 | r#" |
| 2459 | main: () -> i32 { |
| 2460 | n: i32 = 7 |
| 2461 | three: f64 = 3.0 |
| 2462 | f: f64 = n as f64 |
| 2463 | g: f64 = f * three |
| 2464 | return g as i32 |
| 2465 | } |
| 2466 | "#, |
| 2467 | ); |
| 2468 | assert!( |
| 2469 | matches!(outcome, RunOutcome::Halted(21)), |
| 2470 | "expected Halted(21), got {outcome:?}" |
| 2471 | ); |
| 2472 | } |
| 2473 | |
| 2474 | #[test] |
| 2475 | fn float_f32_int_cast() { |
| 2476 | // i32 -> f32 -> i32 with a non-trivial intermediate value. |
| 2477 | let (_, outcome, _) = run_hll( |
| 2478 | r#" |
| 2479 | main: () -> i32 { |