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

Function fill_externref_tables_via_api

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

Source from the content-addressed store, hash-verified

334
335#[test]
336fn fill_externref_tables_via_api() -> wasmtime::Result<()> {
337 let mut cfg = Config::new();
338 cfg.wasm_reference_types(true);
339 let engine = Engine::new(&cfg)?;
340 let mut store = Store::new(&engine, ());
341
342 let table_ty = TableType::new(RefType::EXTERNREF, 10, None);
343 let table = Table::new(&mut store, table_ty, Ref::Extern(None))?;
344
345 for i in 0..10 {
346 assert!(table.get(&mut store, i).unwrap().unwrap_extern().is_none());
347 }
348
349 let val = ExternRef::new(&mut store, 42_usize)?;
350 table.fill(&mut store, 2, val.into(), 4)?;
351
352 for i in (0..2).chain(7..10) {
353 assert!(table.get(&mut store, i).unwrap().unwrap_extern().is_none());
354 }
355 for i in 2..6 {
356 assert_eq!(
357 *table
358 .get(&mut store, i)
359 .unwrap()
360 .unwrap_extern()
361 .unwrap()
362 .data(&store)?
363 .expect("should have host data")
364 .downcast_ref::<usize>()
365 .unwrap(),
366 42
367 );
368 }
369
370 Ok(())
371}
372
373#[test]
374fn grow_externref_tables_via_api() -> wasmtime::Result<()> {

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected