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

Function TestFuncPanic

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

Source from the content-addressed store, hash-verified

47}
48
49func TestFuncPanic(t *testing.T) {
50 store := NewStore(NewEngine())
51 cb := func(caller *Caller, args []Val) ([]Val, *Trap) {
52 panic("x")
53 }
54 f := NewFunc(store, NewFuncType([]*ValType{}, []*ValType{}), cb)
55 var caught interface{}
56 var results interface{}
57 var err error
58 func() {
59 defer func() { caught = recover() }()
60 results, err = f.Call(store)
61 }()
62 require.NotNil(t, caught, "panic didn't work")
63 require.IsType(t, caught, string(""))
64 require.IsType(t, caught.(string), "x", "value didn't propagate")
65 require.NoError(t, err, "bad trap")
66 require.Nil(t, results, "bad results")
67}
68
69func TestFuncArgs(t *testing.T) {
70 store := NewStore(NewEngine())

Callers

nothing calls this directly

Calls 5

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