...
1 package emscripten
2
3 import (
4 "context"
5 "testing"
6
7 "github.com/tetratelabs/wazero/api"
8 "github.com/tetratelabs/wazero/experimental/wazerotest"
9 "github.com/tetratelabs/wazero/internal/testing/require"
10 )
11
12 func Test_callOnPanic(t *testing.T) {
13 const exists = "f"
14 var called bool
15 f := wazerotest.NewFunction(func(context.Context, api.Module) { called = true })
16 f.ExportNames = []string{exists}
17 m := wazerotest.NewModule(nil, f)
18 t.Run("exists", func(t *testing.T) {
19 callOrPanic(context.Background(), m, exists, nil)
20 require.True(t, called)
21 })
22 t.Run("not exist", func(t *testing.T) {
23 err := require.CapturePanic(func() { callOrPanic(context.Background(), m, "not-exist", nil) })
24 require.EqualError(t, err, "not-exist not exported")
25 })
26 }
27
View as plain text