(config: &mut Config)
| 185 | |
| 186 | #[wasmtime_test(wasm_features(exceptions))] |
| 187 | fn exception_across_no_wasm(config: &mut Config) -> Result<()> { |
| 188 | let engine = Engine::new(config)?; |
| 189 | let mut store = Store::new(&engine, ()); |
| 190 | |
| 191 | let functy = FuncType::new(&engine, [ValType::I32], []); |
| 192 | let tagty = TagType::new(functy.clone()); |
| 193 | let exnty = ExnType::from_tag_type(&tagty).unwrap(); |
| 194 | let exnpre = ExnRefPre::new(&mut store, exnty); |
| 195 | let tag = Tag::new(&mut store, &tagty)?; |
| 196 | let extfunc = Func::new(&mut store, functy, move |mut caller, args, _rets| { |
| 197 | let exn = ExnRef::new( |
| 198 | &mut caller, |
| 199 | &exnpre, |
| 200 | &tag, |
| 201 | &[Val::I32(args[0].unwrap_i32())], |
| 202 | ) |
| 203 | .unwrap(); |
| 204 | caller.as_context_mut().throw(exn)?; |
| 205 | Ok(()) |
| 206 | }); |
| 207 | let mut results = []; |
| 208 | let result = extfunc.call(&mut store, &[Val::I32(42)], &mut results[..]); |
| 209 | assert!(result.is_err() && result.unwrap_err().downcast::<ThrownException>().is_ok()); |
| 210 | let exn = store.take_pending_exception().unwrap(); |
| 211 | let exntag = exn.tag(&mut store)?; |
| 212 | assert!(Tag::eq(&exntag, &tag, &store)); |
| 213 | assert_eq!(exn.field(&mut store, 0)?.unwrap_i32(), 42); |
| 214 | |
| 215 | Ok(()) |
| 216 | } |
| 217 | |
| 218 | #[wasmtime_test(wasm_features(gc, exceptions))] |
| 219 | #[cfg_attr(miri, ignore)] |
nothing calls this directly
no test coverage detected