MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / maps_large

Function maps_large

tests/all/component_model/dynamic.rs:443–474  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

441
442#[test]
443fn 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]
477fn records() -> Result<()> {

Callers

nothing calls this directly

Calls 12

map_engineFunction · 0.85
make_echo_componentFunction · 0.85
OkFunction · 0.85
collectMethod · 0.80
newFunction · 0.50
MapClass · 0.50
instantiateMethod · 0.45
unwrapMethod · 0.45
get_funcMethod · 0.45
mapMethod · 0.45
callMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected