MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime-go / TestInstanceGetFunc

Function TestInstanceGetFunc

instance_test.go:72–99  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

70}
71
72func TestInstanceGetFunc(t *testing.T) {
73 wasm, err := Wat2Wasm(`
74 (module
75 (func (export "f") (nop))
76 (global (export "g") i32 (i32.const 0))
77 )
78 `)
79 require.NoError(t, err)
80
81 store := NewStore(NewEngine())
82 module, err := NewModule(store.Engine, wasm)
83 require.NoError(t, err)
84
85 instance, err := NewInstance(store, module, []AsExtern{})
86 require.NoError(t, err)
87
88 f := instance.GetFunc(store, "f")
89 require.NotNil(t, f, "expected a function")
90
91 _, err = f.Call(store)
92 require.NoError(t, err)
93
94 f = instance.GetFunc(store, "g")
95 require.Nil(t, f, "expected an error")
96
97 f = instance.GetFunc(store, "f2")
98 require.Nil(t, f, "expected an error")
99}

Callers

nothing calls this directly

Calls 7

GetFuncMethod · 0.95
Wat2WasmFunction · 0.85
NewStoreFunction · 0.85
NewEngineFunction · 0.85
NewModuleFunction · 0.85
NewInstanceFunction · 0.85
CallMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…