From b73b9d8bc68ef53ae6ade149809f9f84c0b8a80a Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 5 Apr 2026 22:13:12 +0100 Subject: Add test for int values --- patio-to-cranelift/src/codegen/values.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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]); + } } -- cgit v1.2.3