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

Function signatures_match

tests/all/host_funcs.rs:133–228  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

131
132#[test]
133fn signatures_match() -> Result<()> {
134 let engine = Engine::default();
135 let mut linker = Linker::<()>::new(&engine);
136
137 linker.func_wrap("", "f1", || {})?;
138 linker.func_wrap("", "f2", || -> i32 {
139 loop {}
140 })?;
141 linker.func_wrap("", "f3", || -> i64 {
142 loop {}
143 })?;
144 linker.func_wrap("", "f4", || -> f32 {
145 loop {}
146 })?;
147 linker.func_wrap("", "f5", || -> f64 {
148 loop {}
149 })?;
150 linker.func_wrap(
151 "",
152 "f6",
153 |_: f32,
154 _: f64,
155 _: i32,
156 _: i64,
157 _: i32,
158 _: Option<Rooted<ExternRef>>,
159 _: Option<Func>|
160 -> f64 { loop {} },
161 )?;
162
163 let mut store = Store::new(&engine, ());
164
165 let f = linker
166 .get(&mut store, "", "f1")
167 .unwrap()
168 .into_func()
169 .unwrap();
170 assert_eq!(f.ty(&store).params().len(), 0);
171 assert_eq!(f.ty(&store).results().len(), 0);
172
173 let f = linker
174 .get(&mut store, "", "f2")
175 .unwrap()
176 .into_func()
177 .unwrap();
178 assert_eq!(f.ty(&store).params().len(), 0);
179 assert_eq!(f.ty(&store).results().len(), 1);
180 assert!(f.ty(&store).results().nth(0).unwrap().is_i32());
181
182 let f = linker
183 .get(&mut store, "", "f3")
184 .unwrap()
185 .into_func()
186 .unwrap();
187 assert_eq!(f.ty(&store).params().len(), 0);
188 assert_eq!(f.ty(&store).results().len(), 1);
189 assert!(f.ty(&store).results().nth(0).unwrap().is_i64());
190

Callers

nothing calls this directly

Calls 6

OkFunction · 0.85
newFunction · 0.50
func_wrapMethod · 0.45
unwrapMethod · 0.45
into_funcMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected