()
| 311 | |
| 312 | #[test] |
| 313 | fn maps_duplicate_keys() -> Result<()> { |
| 314 | let engine = super::map_engine(); |
| 315 | let mut store = Store::new(&engine, ()); |
| 316 | |
| 317 | let component = Component::new(&engine, make_echo_component("(map u32 string)", 8))?; |
| 318 | let instance = Linker::new(&engine).instantiate(&mut store, &component)?; |
| 319 | let func = instance.get_func(&mut store, "echo").unwrap(); |
| 320 | |
| 321 | // Create a map with duplicate keys - Vec preserves all entries |
| 322 | let input_map = vec![ |
| 323 | (Val::U32(1), Val::String("first".into())), |
| 324 | (Val::U32(1), Val::String("last".into())), // Duplicate key |
| 325 | (Val::U32(2), Val::String("two".into())), |
| 326 | ]; |
| 327 | let input = Val::Map(input_map); |
| 328 | |
| 329 | let mut output = [Val::Bool(false)]; |
| 330 | func.call(&mut store, &[input.clone()], &mut output)?; |
| 331 | |
| 332 | // Verify all entries are preserved (Vec doesn't deduplicate) |
| 333 | match &output[0] { |
| 334 | Val::Map(output_map) => { |
| 335 | // Should have 3 entries (Vec preserves duplicates) |
| 336 | assert_eq!(output_map.len(), 3); |
| 337 | } |
| 338 | _ => panic!("expected map"), |
| 339 | } |
| 340 | |
| 341 | Ok(()) |
| 342 | } |
| 343 | |
| 344 | #[test] |
| 345 | fn maps_all_primitive_types() -> Result<()> { |
nothing calls this directly
no test coverage detected