Path: blob/main/crates/c-api/tests/component/lookup_func.cc
3068 views
#include <gtest/gtest.h>1#include <wasmtime/component.hh>2#include <wasmtime/store.hh>34using namespace wasmtime::component;56TEST(component, lookup_func) {7static constexpr auto component_text = std::string_view{8R"END(9(component10(core module $m11(func (export "f"))12)13(core instance $i (instantiate $m))14(func (export "f")15(canon lift (core func $i "f")))16)17)END",18};1920wasmtime::Engine engine;21wasmtime::Store store(engine);22auto context = store.context();23Component component = Component::compile(engine, component_text).unwrap();24auto f = component.export_index(nullptr, "ff");2526EXPECT_FALSE(f);2728f = component.export_index(nullptr, "f");2930EXPECT_TRUE(f);3132Linker linker(engine);3334auto instance = linker.instantiate(context, component).unwrap();3536*instance.get_func(context, *f);3738auto f2 = instance.get_export_index(context, nullptr, "f");39EXPECT_TRUE(f2);40}414243