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

Function fill_funcref_tables_via_api

tests/all/externals.rs:263–287  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

261
262#[test]
263fn fill_funcref_tables_via_api() -> wasmtime::Result<()> {
264 let mut cfg = Config::new();
265 cfg.wasm_reference_types(true);
266 let engine = Engine::new(&cfg)?;
267 let mut store = Store::new(&engine, ());
268
269 let table_ty = TableType::new(RefType::FUNCREF, 10, None);
270 let table = Table::new(&mut store, table_ty, Ref::Func(None))?;
271
272 for i in 0..10 {
273 assert!(table.get(&mut store, i).unwrap().unwrap_func().is_none());
274 }
275
276 let fill = Ref::Func(Some(Func::wrap(&mut store, || {})));
277 table.fill(&mut store, 2, fill, 4)?;
278
279 for i in (0..2).chain(7..10) {
280 assert!(table.get(&mut store, i).unwrap().unwrap_func().is_none());
281 }
282 for i in 2..6 {
283 assert!(table.get(&mut store, i).unwrap().unwrap_func().is_some());
284 }
285
286 Ok(())
287}
288
289#[test]
290fn grow_funcref_tables_via_api() -> wasmtime::Result<()> {

Callers

nothing calls this directly

Calls 6

OkFunction · 0.85
chainMethod · 0.80
newFunction · 0.50
FuncEnum · 0.50
wasm_reference_typesMethod · 0.45
fillMethod · 0.45

Tested by

no test coverage detected