()
| 208 | |
| 209 | #[test] |
| 210 | fn get_set_funcref_globals_via_api() -> wasmtime::Result<()> { |
| 211 | let mut cfg = Config::new(); |
| 212 | cfg.wasm_reference_types(true); |
| 213 | let engine = Engine::new(&cfg)?; |
| 214 | let mut store = Store::new(&engine, ()); |
| 215 | |
| 216 | let f = Func::wrap(&mut store, || {}); |
| 217 | |
| 218 | // Initialize with a null funcref. |
| 219 | |
| 220 | let global = Global::new( |
| 221 | &mut store, |
| 222 | GlobalType::new(ValType::FUNCREF, Mutability::Var), |
| 223 | Val::FuncRef(None), |
| 224 | )?; |
| 225 | assert!(global.get(&mut store).unwrap_funcref().is_none()); |
| 226 | |
| 227 | global.set(&mut store, Val::FuncRef(Some(f)))?; |
| 228 | let f2 = global.get(&mut store).unwrap_funcref().cloned().unwrap(); |
| 229 | assert!(FuncType::eq(&f.ty(&store), &f2.ty(&store))); |
| 230 | |
| 231 | // Initialize with a non-null funcref. |
| 232 | |
| 233 | let global = Global::new( |
| 234 | &mut store, |
| 235 | GlobalType::new(ValType::FUNCREF, Mutability::Var), |
| 236 | Val::FuncRef(Some(f)), |
| 237 | )?; |
| 238 | let f2 = global.get(&mut store).unwrap_funcref().cloned().unwrap(); |
| 239 | assert!(FuncType::eq(&f.ty(&store), &f2.ty(&store))); |
| 240 | |
| 241 | Ok(()) |
| 242 | } |
| 243 | |
| 244 | #[test] |
| 245 | fn create_get_set_funcref_tables_via_api() -> wasmtime::Result<()> { |
nothing calls this directly
no test coverage detected