| 5 | using namespace wasmtime; |
| 6 | |
| 7 | TEST(Linker, Smoke) { |
| 8 | Engine engine; |
| 9 | Linker linker(engine); |
| 10 | Store store(engine); |
| 11 | linker.allow_shadowing(false); |
| 12 | Global g = |
| 13 | Global::create(store, GlobalType(ValType::i32(), false), 1).unwrap(); |
| 14 | linker.define(store, "a", "g", g).unwrap(); |
| 15 | linker.define_wasi().unwrap(); |
| 16 | linker |
| 17 | .func_new("a", "f", FuncType({}, {}), |
| 18 | [](auto caller, auto params, auto results) -> auto { |
| 19 | return std::monostate(); |
| 20 | }) |
| 21 | .unwrap(); |
| 22 | linker.func_wrap("a", "f2", []() {}).unwrap(); |
| 23 | linker.func_wrap("a", "f3", [](Caller arg) {}).unwrap(); |
| 24 | linker.func_wrap("a", "f4", [](Caller arg, int32_t a) {}).unwrap(); |
| 25 | Module mod = Module::compile(engine, "(module)").unwrap(); |
| 26 | Instance i = Instance::create(store, mod, {}).unwrap(); |
| 27 | linker.define_instance(store, "x", i).unwrap(); |
| 28 | linker.instantiate(store, mod).unwrap(); |
| 29 | linker.module(store, "y", mod).unwrap(); |
| 30 | EXPECT_TRUE(linker.get(store, "a", "g")); |
| 31 | linker.get_default(store, "g").unwrap(); |
| 32 | EXPECT_TRUE(linker.get(store, "a", "f")); |
| 33 | EXPECT_TRUE(std::holds_alternative<Func>(*linker.get(store, "a", "f"))); |
| 34 | } |
| 35 | |
| 36 | TEST(Linker, CallableMove) { |
| 37 | Engine engine; |
nothing calls this directly
no test coverage detected