()
| 8 | |
| 9 | #[test] |
| 10 | fn call_exported_func() -> Result<()> { |
| 11 | let module_bytes = { |
| 12 | let mut config = Config::new(); |
| 13 | config.concurrency_support(false); |
| 14 | let engine = Engine::new(&config)?; |
| 15 | let module = Module::new( |
| 16 | &engine, |
| 17 | r#" |
| 18 | (module |
| 19 | (func (export "add") (param i32 i32) (result i32) |
| 20 | (i32.add (local.get 0) (local.get 1)) |
| 21 | ) |
| 22 | ) |
| 23 | "#, |
| 24 | )?; |
| 25 | module.serialize()? |
| 26 | }; |
| 27 | |
| 28 | let mut config = Config::new(); |
| 29 | config.enable_compiler(false); |
| 30 | config.concurrency_support(false); |
| 31 | let engine = Engine::new(&config)?; |
| 32 | |
| 33 | let module = unsafe { Module::deserialize(&engine, &module_bytes)? }; |
| 34 | let linker = Linker::<()>::new(&engine); |
| 35 | let instance_pre = linker.instantiate_pre(&module)?; |
| 36 | |
| 37 | OomTest::new().test(|| { |
| 38 | let mut store = Store::try_new(&engine, ())?; |
| 39 | let instance = instance_pre.instantiate(&mut store)?; |
| 40 | let add = instance.get_typed_func::<(i32, i32), i32>(&mut store, "add")?; |
| 41 | let result = add.call(&mut store, (1, 2))?; |
| 42 | assert_eq!(result, 3); |
| 43 | Ok(()) |
| 44 | }) |
| 45 | } |
| 46 | |
| 47 | #[test] |
| 48 | fn instance_new() -> Result<()> { |
nothing calls this directly
no test coverage detected