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

Function TestFuncWrongRet

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

Source from the content-addressed store, hash-verified

102}
103
104func TestFuncWrongRet(t *testing.T) {
105 store := NewStore(NewEngine())
106 cb := func(caller *Caller, args []Val) ([]Val, *Trap) {
107 return []Val{ValI64(3)}, nil
108 }
109 i32 := NewValType(KindI32)
110 f := NewFunc(store, NewFuncType([]*ValType{}, []*ValType{i32}), cb)
111
112 var caught interface{}
113 func() {
114 defer func() { caught = recover() }()
115 f.Call(store)
116 }()
117 require.NotNil(t, caught, "expected a panic")
118 require.IsType(t, caught, string(""))
119 require.Containsf(t, caught.(string), "callback produced wrong type of result", "wrong panic message %s", caught)
120}
121
122func TestFuncWrongRet2(t *testing.T) {
123 store := NewStore(NewEngine())

Callers

nothing calls this directly

Calls 7

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