| 261 | |
| 262 | #[test] |
| 263 | fn 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] |
| 290 | fn grow_funcref_tables_via_api() -> wasmtime::Result<()> { |