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

Function test_many_call_module

tests/all/relocs.rs:93–123  ·  view source on GitHub ↗
(mut store: Store<()>)

Source from the content-addressed store, hash-verified

91}
92
93fn test_many_call_module(mut store: Store<()>) -> Result<()> {
94 const N: i32 = 200;
95
96 let mut wat = String::new();
97 wat.push_str("(module\n");
98 wat.push_str("(func $first (result i32) (i32.const 1))\n");
99 for i in 0..N {
100 wat.push_str(&format!("(func (export \"{i}\") (result i32 i32)\n"));
101 wat.push_str("call $first\n");
102 wat.push_str(&format!("i32.const {i}\n"));
103 wat.push_str("i32.add\n");
104 wat.push_str("call $last\n");
105 wat.push_str(&format!("i32.const {i}\n"));
106 wat.push_str("i32.add)\n");
107 }
108 wat.push_str("(func $last (result i32) (i32.const 2))\n");
109 wat.push_str(")\n");
110
111 let module = Module::new(store.engine(), &wat)?;
112
113 let instance = Instance::new(&mut store, &module, &[])?;
114
115 for i in 0..N {
116 let name = i.to_string();
117 let func = instance.get_typed_func::<(), (i32, i32)>(&mut store, &name)?;
118 let (a, b) = func.call(&mut store, ())?;
119 assert_eq!(a, i + 1);
120 assert_eq!(b, i + 2);
121 }
122 Ok(())
123}

Callers 2

mixedFunction · 0.85
mixed_forcedFunction · 0.85

Calls 6

OkFunction · 0.85
newFunction · 0.50
push_strMethod · 0.45
engineMethod · 0.45
to_stringMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected