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

Function maps_duplicate_keys

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

Source from the content-addressed store, hash-verified

311
312#[test]
313fn 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]
345fn maps_all_primitive_types() -> Result<()> {

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected