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

Function TestFuncOneRet

func_test.go:90–102  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

88}
89
90func TestFuncOneRet(t *testing.T) {
91 store := NewStore(NewEngine())
92 cb := func(caller *Caller, args []Val) ([]Val, *Trap) {
93 require.Empty(t, args, "wrong argument size")
94 return []Val{ValI32(3)}, nil
95 }
96 i32 := NewValType(KindI32)
97 f := NewFunc(store, NewFuncType([]*ValType{}, []*ValType{i32}), cb)
98 results, trap := f.Call(store)
99 require.Nil(t, trap)
100 require.IsType(t, results, int32(0))
101 require.Equal(t, int32(3), results.(int32), "bad result")
102}
103
104func TestFuncWrongRet(t *testing.T) {
105 store := NewStore(NewEngine())

Callers

nothing calls this directly

Calls 7

CallMethod · 0.95
NewStoreFunction · 0.85
NewEngineFunction · 0.85
ValI32Function · 0.85
NewValTypeFunction · 0.85
NewFuncFunction · 0.85
NewFuncTypeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…