| 924 | #[wasmtime_test] |
| 925 | #[cfg_attr(miri, ignore)] |
| 926 | fn get_from_module(config: &mut Config) -> wasmtime::Result<()> { |
| 927 | let engine = Engine::new(&config)?; |
| 928 | let mut store = Store::<()>::new(&engine, ()); |
| 929 | let module = Module::new( |
| 930 | store.engine(), |
| 931 | r#" |
| 932 | (module |
| 933 | (func (export "f0")) |
| 934 | (func (export "f1") (param i32)) |
| 935 | (func (export "f2") (result i32) |
| 936 | i32.const 0) |
| 937 | ) |
| 938 | |
| 939 | "#, |
| 940 | )?; |
| 941 | let instance = Instance::new(&mut store, &module, &[])?; |
| 942 | let f0 = instance.get_func(&mut store, "f0").unwrap(); |
| 943 | assert!(f0.typed::<(), ()>(&store).is_ok()); |
| 944 | assert!(f0.typed::<(), i32>(&store).is_err()); |
| 945 | let f1 = instance.get_func(&mut store, "f1").unwrap(); |
| 946 | assert!(f1.typed::<(), ()>(&store).is_err()); |
| 947 | assert!(f1.typed::<i32, ()>(&store).is_ok()); |
| 948 | assert!(f1.typed::<i32, f32>(&store).is_err()); |
| 949 | let f2 = instance.get_func(&mut store, "f2").unwrap(); |
| 950 | assert!(f2.typed::<(), ()>(&store).is_err()); |
| 951 | assert!(f2.typed::<(), i32>(&store).is_ok()); |
| 952 | assert!(f2.typed::<i32, ()>(&store).is_err()); |
| 953 | assert!(f2.typed::<i32, f32>(&store).is_err()); |
| 954 | Ok(()) |
| 955 | } |
| 956 | |
| 957 | #[test] |
| 958 | fn call_wrapped_func() -> Result<()> { |