| 1936 | return 1 |
| 1937 | } |
| 1938 | "#, |
| 1939 | ); |
| 1940 | assert!( |
| 1941 | matches!(outcome, RunOutcome::Halted(0)), |
| 1942 | "struct fields x=3 y=7 must be readable at correct offsets, got {outcome:?}" |
| 1943 | ); |
| 1944 | } |
| 1945 | |
| 1946 | /// Struct field arithmetic: compute a value from both fields. |
| 1947 | #[test] |
| 1948 | fn struct_field_arithmetic() { |
| 1949 | let (_, outcome, _) = run_hll( |
| 1950 | r#" |
| 1951 | divide: (a: i32, b: i32) -> { quotient: i32, remainder: i32 } { |
| 1952 | return { .quotient = a / b, .remainder = a % b } |
| 1953 | } |
| 1954 | |
| 1955 | main: () -> i32 { |
| 1956 | { quotient: i32, remainder: i32 } = divide(23, 7) |
| 1957 | sum: i32 = quotient + remainder |
| 1958 | if sum == 5 { |