diff --git a/linera-witty/tests/common/types.rs b/linera-witty/tests/common/types.rs index 8b2bc439250..006f1c2f679 100644 --- a/linera-witty/tests/common/types.rs +++ b/linera-witty/tests/common/types.rs @@ -3,7 +3,7 @@ //! Dummy types used in tests. -use std::rc::Rc; +use std::{rc::Rc, sync::Arc}; use linera_witty::{WitLoad, WitStore, WitType}; @@ -76,4 +76,5 @@ pub enum SpecializedGenericEnum { pub struct StructWithHeapFields { pub boxed: Box, pub rced: Rc, + pub arced: Arc, } diff --git a/linera-witty/tests/wit_load.rs b/linera-witty/tests/wit_load.rs index 2c2d0e0ee30..8580072b83a 100644 --- a/linera-witty/tests/wit_load.rs +++ b/linera-witty/tests/wit_load.rs @@ -317,12 +317,16 @@ fn test_heap_allocated_fields() { first: false, second: 0x201f_1e1d_1c1b_1a19_1817_1615_1413_1211_u128, }), + arced: Arc::new(Enum::SmallerVariantWithStrictAlignment { + inner: 0x2f2e_2d2c_2b2a_2928, + }), }; test_load_from_memory( &[ 1, 2, 3, 4, 5, 6, 7, 8, 0, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, + 25, 26, 27, 28, 29, 30, 31, 32, 2, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, + 46, 47, 48, ], expected.clone(), ); @@ -332,6 +336,17 @@ fn test_heap_allocated_fields() { 0_i32, 0x1817_1615_1413_1211_i64, 0x201f_1e1d_1c1b_1a19_i64, + 2_i32, + 0x2f2e_2d2c_2b2a_2928_i64, + 0_i32, + 0_i32, + 0_i32, + 0_i32, + 0_i32, + 0_i32, + 0_i32, + 0_i32, + 0_i32, ], expected, &[], diff --git a/linera-witty/tests/wit_store.rs b/linera-witty/tests/wit_store.rs index 8b7be054a87..68ff2693b95 100644 --- a/linera-witty/tests/wit_store.rs +++ b/linera-witty/tests/wit_store.rs @@ -363,13 +363,17 @@ fn test_heap_allocated_fields() { first: true, second: 0x7071_7273_7475_7677_7879_7a7b_7c7d_7e7f_u128, }), + arced: Arc::new(Enum::SmallerVariantWithStrictAlignment { + inner: 0x4041_4243_4445_4647_u64, + }), }; test_store_in_memory( data.clone(), &[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0x7f, 0x7e, 0x7d, 0x7c, 0x7b, 0x7a, - 0x79, 0x78, 0x77, 0x76, 0x75, 0x74, 0x73, 0x72, 0x71, 0x70, + 0x79, 0x78, 0x77, 0x76, 0x75, 0x74, 0x73, 0x72, 0x71, 0x70, 2, 0, 0, 0, 0, 0, 0, 0, + 0x47, 0x46, 0x45, 0x44, 0x43, 0x42, 0x41, 0x40, 0, 0, 0, 0, 0, 0, 0, 0, ], &[], ); @@ -380,6 +384,17 @@ fn test_heap_allocated_fields() { 1_i32, 0x7879_7a7b_7c7d_7e7f_i64, 0x7071_7273_7475_7677_i64, + 2_i32, + 0x4041_4243_4445_4647_i64, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, ], &[], ); diff --git a/linera-witty/tests/wit_type.rs b/linera-witty/tests/wit_type.rs index 9d672df6cab..4f9094c25d3 100644 --- a/linera-witty/tests/wit_type.rs +++ b/linera-witty/tests/wit_type.rs @@ -181,10 +181,17 @@ fn test_specialized_generic_enum_type() { #[test] fn test_heap_allocated_fields() { test_wit_type_implementation::(ExpectedMetadata { - size: 32, + size: 56, alignment: 8, - flat_layout_length: 4, + flat_layout_length: 15, declaration: concat!( + " variant enum {\n", + " empty,\n", + " large-variant-with-loose-alignment(\ + tuple\ + ),\n", + " smaller-variant-with-strict-alignment(u64),\n", + " }\n\n", " record leaf {\n", " first: bool,\n", " second: u128,\n", @@ -195,6 +202,7 @@ fn test_heap_allocated_fields() { " record struct-with-heap-fields {\n", " boxed: simple-wrapper,\n", " rced: leaf,\n", + " arced: enum,\n", " }\n\n", " type u128 = tuple;\n", ),