diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-04-05 22:13:12 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-04-05 22:13:12 +0100 |
| commit | b73b9d8bc68ef53ae6ade149809f9f84c0b8a80a (patch) | |
| tree | c9d549d8acb63acf53eca2e2b7fa7b43672f7e11 | |
| parent | 7e0306b56f3cded667b681a09de13162ab4fc17b (diff) | |
Add test for int values
| -rw-r--r-- | patio-to-cranelift/src/codegen/values.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/patio-to-cranelift/src/codegen/values.rs b/patio-to-cranelift/src/codegen/values.rs index 0d5861bf..c0f60517 100644 --- a/patio-to-cranelift/src/codegen/values.rs +++ b/patio-to-cranelift/src/codegen/values.rs @@ -69,7 +69,7 @@ pub(crate) fn eval_int_value(value: &PatioIntValue, target_triple: &target_lexic mod data_value_to_bytes_test { use std::str::FromStr; - use crate::patio::values::PatioDataValue; + use crate::patio::values::{PatioDataValue, PatioIntValue}; fn data_value_to_bytes(data_value: PatioDataValue) -> Box<[u8]> { super::data_value_to_bytes( @@ -104,4 +104,13 @@ mod data_value_to_bytes_test { assert_eq!(bytes.as_ref(), &[42]); } + + #[test] + fn given_pointer_is_at_least_32_bits_wide_then_int_is_written_with_pointer_width() { + let data_value = PatioDataValue::Int(PatioIntValue::Literal { value: 0x12345678 }); + + let bytes = data_value_to_bytes(data_value); + + assert_eq!(bytes.as_ref(), &[0x78, 0x56, 0x34, 0x12, 0, 0, 0, 0]); + } } |
