| 2557 | r#" |
| 2558 | main: () -> i32 { |
| 2559 | a: f64 = 5.0 |
| 2560 | eight: f64 = 8.0 |
| 2561 | b: f64 = -a |
| 2562 | c: f64 = b + eight |
| 2563 | return c as i32 |
| 2564 | } |
| 2565 | "#, |
| 2566 | ); |
| 2567 | assert!( |
| 2568 | matches!(outcome, RunOutcome::Halted(3)), |
| 2569 | "expected Halted(3), got {outcome:?}" |
| 2570 | ); |
| 2571 | } |
| 2572 | |
| 2573 | #[test] |
| 2574 | fn float_f32_comparison() { |
| 2575 | // f32 less-than comparison must use flt.s. |
| 2576 | let (_, outcome, _) = run_hll( |
| 2577 | r#" |
| 2578 | main: () -> i32 { |
| 2579 | a: f32 = 1.5 |
| 2580 | b: f32 = 2.5 |
| 2581 | if a < b { |
| 2582 | return 1 |
| 2583 | } |
| 2584 | return 0 |
| 2585 | } |
| 2586 | "#, |
| 2587 | ); |
| 2588 | assert!( |
| 2589 | matches!(outcome, RunOutcome::Halted(1)), |
| 2590 | "expected Halted(1), got {outcome:?}" |
| 2591 | ); |
| 2592 | } |
| 2593 | |
| 2594 | #[test] |
| 2595 | fn float_f64_comparison() { |
| 2596 | // f64 equality must use feq.d (not the integer comparator). |
| 2597 | let (_, outcome, _) = run_hll( |
| 2598 | r#" |
| 2599 | main: () -> i32 { |
| 2600 | a: f64 = 5.5 |
| 2601 | b: f64 = 2.5 |
| 2602 | eight: f64 = 8.0 |
| 2603 | c: f64 = a + b |