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

Function TestFuncTrap

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

Source from the content-addressed store, hash-verified

30}
31
32func TestFuncTrap(t *testing.T) {
33 store := NewStore(NewEngine())
34 cb := func(caller *Caller, args []Val) ([]Val, *Trap) {
35 return nil, NewTrap("x")
36 }
37 f := NewFunc(store, NewFuncType([]*ValType{}, []*ValType{}), cb)
38 results, err := f.Call(store)
39 require.Error(t, err, "bad trap")
40 if results != nil {
41 panic("bad results")
42 }
43 trap := err.(*Error)
44 if trap.Error() != "x" {
45 panic("bad message")
46 }
47}
48
49func TestFuncPanic(t *testing.T) {
50 store := NewStore(NewEngine())

Callers

nothing calls this directly

Calls 7

CallMethod · 0.95
NewStoreFunction · 0.85
NewEngineFunction · 0.85
NewTrapFunction · 0.85
NewFuncFunction · 0.85
NewFuncTypeFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…