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

Function TestFuncWrongRet2

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

Source from the content-addressed store, hash-verified

120}
121
122func TestFuncWrongRet2(t *testing.T) {
123 store := NewStore(NewEngine())
124 cb := func(caller *Caller, args []Val) ([]Val, *Trap) {
125 return []Val{}, nil
126 }
127 i32 := NewValType(KindI32)
128 f := NewFunc(store, NewFuncType([]*ValType{}, []*ValType{i32}), cb)
129
130 var caught interface{}
131 func() {
132 defer func() { caught = recover() }()
133 f.Call(store)
134 }()
135 require.NotNil(t, caught, "expected a panic")
136 require.IsType(t, caught, string(""))
137 require.Containsf(t, caught.(string), "callback didn't produce the correct number of results", "wrong panic message %s", caught)
138}
139
140func TestFuncWrapSimple(t *testing.T) {
141 store := NewStore(NewEngine())

Callers

nothing calls this directly

Calls 6

CallMethod · 0.95
NewStoreFunction · 0.85
NewEngineFunction · 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…