()
| 441 | |
| 442 | #[test] |
| 443 | fn maps_large() -> Result<()> { |
| 444 | let engine = super::map_engine(); |
| 445 | let mut store = Store::new(&engine, ()); |
| 446 | |
| 447 | let component = Component::new(&engine, make_echo_component("(map u32 string)", 8))?; |
| 448 | let instance = Linker::new(&engine).instantiate(&mut store, &component)?; |
| 449 | let func = instance.get_func(&mut store, "echo").unwrap(); |
| 450 | |
| 451 | // Create a map with many entries |
| 452 | let input_map: Vec<(Val, Val)> = (0..100) |
| 453 | .map(|i| (Val::U32(i), Val::String(format!("value_{i}")))) |
| 454 | .collect(); |
| 455 | let input = Val::Map(input_map); |
| 456 | |
| 457 | let mut output = [Val::Bool(false)]; |
| 458 | func.call(&mut store, &[input.clone()], &mut output)?; |
| 459 | |
| 460 | // Verify all entries are present |
| 461 | match &output[0] { |
| 462 | Val::Map(output_map) => { |
| 463 | assert_eq!(output_map.len(), 100); |
| 464 | for i in 0..100 { |
| 465 | assert!(output_map.iter().any(|(k, v)| { |
| 466 | *k == Val::U32(i) && *v == Val::String(format!("value_{i}")) |
| 467 | })); |
| 468 | } |
| 469 | } |
| 470 | _ => panic!("expected map"), |
| 471 | } |
| 472 | |
| 473 | Ok(()) |
| 474 | } |
| 475 | |
| 476 | #[test] |
| 477 | fn records() -> Result<()> { |
nothing calls this directly
no test coverage detected