()
| 317 | #[test] |
| 318 | #[cfg_attr(miri, ignore)] |
| 319 | fn table_init() -> Result<()> { |
| 320 | let mut pool = crate::small_pool_config(); |
| 321 | pool.max_memory_size(0).table_elements(6); |
| 322 | let mut config = Config::new(); |
| 323 | config.allocation_strategy(pool); |
| 324 | |
| 325 | let engine = Engine::new(&config)?; |
| 326 | |
| 327 | let module = Module::new( |
| 328 | &engine, |
| 329 | r#" |
| 330 | (module |
| 331 | (table (export "t") 6 funcref) |
| 332 | (elem (i32.const 1) 1 2 3 4) |
| 333 | (elem (i32.const 0) 0) |
| 334 | (func) |
| 335 | (func (param i32)) |
| 336 | (func (param i32 i32)) |
| 337 | (func (param i32 i32 i32)) |
| 338 | (func (param i32 i32 i32 i32)) |
| 339 | ) |
| 340 | "#, |
| 341 | )?; |
| 342 | |
| 343 | let mut store = Store::new(&engine, ()); |
| 344 | let instance = Instance::new(&mut store, &module, &[])?; |
| 345 | let table = instance.get_table(&mut store, "t").unwrap(); |
| 346 | |
| 347 | for i in 0..5 { |
| 348 | let v = table.get(&mut store, i).expect("table should have entry"); |
| 349 | let f = v |
| 350 | .as_func() |
| 351 | .expect("expected funcref") |
| 352 | .expect("expected non-null value"); |
| 353 | assert_eq!(f.ty(&store).params().len(), i as usize); |
| 354 | } |
| 355 | |
| 356 | assert!( |
| 357 | table |
| 358 | .get(&mut store, 5) |
| 359 | .expect("table should have entry") |
| 360 | .as_func() |
| 361 | .expect("expected funcref") |
| 362 | .is_none(), |
| 363 | "funcref should be null" |
| 364 | ); |
| 365 | |
| 366 | Ok(()) |
| 367 | } |
| 368 | |
| 369 | #[test] |
| 370 | fn table_zeroed() -> Result<()> { |
nothing calls this directly
no test coverage detected