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

Function call_array_to_wasm

tests/all/func.rs:162–189  ·  view source on GitHub ↗
(config: &mut Config)

Source from the content-addressed store, hash-verified

160#[wasmtime_test]
161#[cfg_attr(miri, ignore)]
162fn call_array_to_wasm(config: &mut Config) -> Result<()> {
163 let wasm = wat::parse_str(
164 r#"
165 (module
166 (func (export "run") (param i32 i32 i32) (result i32 i32 i32)
167 local.get 1
168 local.get 2
169 local.get 0
170 )
171 )
172 "#,
173 )?;
174 let engine = Engine::new(&config)?;
175 let mut store = Store::<()>::new(&engine, ());
176 let module = Module::new(store.engine(), &wasm)?;
177 let instance = Instance::new(&mut store, &module, &[])?;
178 let func = instance.get_func(&mut store, "run").unwrap();
179 let mut results = [Val::I32(0), Val::I32(0), Val::I32(0)];
180 func.call(
181 &mut store,
182 &[Val::I32(10), Val::I32(20), Val::I32(30)],
183 &mut results,
184 )?;
185 assert_eq!(results[0].i32(), Some(20));
186 assert_eq!(results[1].i32(), Some(30));
187 assert_eq!(results[2].i32(), Some(10));
188 Ok(())
189}
190
191#[test]
192fn call_array_to_native() -> Result<()> {

Callers

nothing calls this directly

Calls 6

OkFunction · 0.85
newFunction · 0.50
engineMethod · 0.45
unwrapMethod · 0.45
get_funcMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected