| 7 | using namespace wasmtime; |
| 8 | |
| 9 | TEST(async, call_func_async) { |
| 10 | Engine engine; |
| 11 | Store store(engine); |
| 12 | auto context = store.context(); |
| 13 | |
| 14 | Module m = Module::compile( |
| 15 | engine, "(module" |
| 16 | " (func (export \"f\") (param i32 i32) (result i32)" |
| 17 | " local.get 0" |
| 18 | " local.get 1" |
| 19 | " i32.add))") |
| 20 | .unwrap(); |
| 21 | |
| 22 | Instance instance = Instance::create(store, m, {}).unwrap(); |
| 23 | auto f = std::get<Func>(*instance.get(store, "f")); |
| 24 | |
| 25 | wasmtime_val_t params[2] = {{.kind = WASMTIME_I32, .of = {.i32 = 34}}, |
| 26 | {.kind = WASMTIME_I32, .of = {.i32 = 35}}}; |
| 27 | wasmtime_val_t results[1] = {}; |
| 28 | wasm_trap_t *trap = nullptr; |
| 29 | wasmtime_error_t *error = nullptr; |
| 30 | |
| 31 | auto *future = wasmtime_func_call_async(context.capi(), &f.capi(), params, 2, |
| 32 | results, 1, &trap, &error); |
| 33 | |
| 34 | while (!wasmtime_call_future_poll(future)) { |
| 35 | } |
| 36 | wasmtime_call_future_delete(future); |
| 37 | |
| 38 | EXPECT_EQ(trap, nullptr); |
| 39 | EXPECT_EQ(error, nullptr); |
| 40 | EXPECT_EQ(results[0].kind, WASMTIME_I32); |
| 41 | EXPECT_EQ(results[0].of.i32, 69); |
| 42 | } |
| 43 | |
| 44 | TEST(async, instantiate_async) { |
| 45 | Engine engine; |
nothing calls this directly
no test coverage detected