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

Function lists

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

Source from the content-addressed store, hash-verified

107
108#[test]
109fn lists() -> Result<()> {
110 let engine = super::engine();
111 let mut store = Store::new(&engine, ());
112
113 let component = Component::new(&engine, make_echo_component("(list u32)", 8))?;
114 let instance = Linker::new(&engine).instantiate(&mut store, &component)?;
115 let func = instance.get_func(&mut store, "echo").unwrap();
116 let input = Val::List(vec![
117 Val::U32(32343),
118 Val::U32(79023439),
119 Val::U32(2084037802),
120 ]);
121 let mut output = [Val::Bool(false)];
122 func.call(&mut store, &[input.clone()], &mut output)?;
123
124 assert_eq!(input, output[0]);
125
126 // Sad path: type mismatch
127
128 let err = Val::List(vec![
129 Val::U32(32343),
130 Val::U32(79023439),
131 Val::Float32(3.14159265),
132 ]);
133 let err = func.call(&mut store, &[err], &mut output).unwrap_err();
134 assert!(err.to_string().contains("type mismatch"), "{err}");
135
136 Ok(())
137}
138
139#[test]
140fn maps() -> Result<()> {

Callers

nothing calls this directly

Calls 10

make_echo_componentFunction · 0.85
OkFunction · 0.85
engineFunction · 0.50
newFunction · 0.50
ListClass · 0.50
instantiateMethod · 0.45
unwrapMethod · 0.45
get_funcMethod · 0.45
callMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected