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

Function TestModuleExports

module_test.go:62–93  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

60}
61
62func TestModuleExports(t *testing.T) {
63 wasm, err := Wat2Wasm(`
64 (module
65 (func (export "f"))
66 (global (export "g") i32 (i32.const 0))
67 (table (export "t") 1 funcref)
68 (memory (export "m") 1)
69 )
70 `)
71 require.NoError(t, err)
72 module, err := NewModule(NewEngine(), wasm)
73 require.NoError(t, err)
74
75 exports := module.Exports()
76 require.Len(t, exports, 4)
77 require.Equal(t, "f", exports[0].Name())
78 require.NotNil(t, exports[0].Type().FuncType())
79 require.Len(t, exports[0].Type().FuncType().Params(), 0)
80 require.Len(t, exports[0].Type().FuncType().Results(), 0)
81
82 require.Equal(t, "g", exports[1].Name())
83 require.NotNil(t, exports[1].Type().GlobalType())
84 require.Equal(t, KindI32, exports[1].Type().GlobalType().Content().Kind())
85
86 require.Equal(t, "t", exports[2].Name())
87 require.NotNil(t, exports[2].Type().TableType())
88 require.Equal(t, KindFuncref, exports[2].Type().TableType().Element().Kind())
89
90 require.Equal(t, "m", exports[3].Name())
91 require.NotNil(t, exports[3].Type().MemoryType())
92 require.Equal(t, uint64(1), exports[3].Type().MemoryType().Minimum())
93}
94
95func TestModuleSerialize(t *testing.T) {
96 engine := NewEngine()

Callers

nothing calls this directly

Calls 15

ExportsMethod · 0.95
Wat2WasmFunction · 0.85
NewModuleFunction · 0.85
NewEngineFunction · 0.85
FuncTypeMethod · 0.80
ParamsMethod · 0.80
ResultsMethod · 0.80
GlobalTypeMethod · 0.80
ContentMethod · 0.80
TableTypeMethod · 0.80
ElementMethod · 0.80
MemoryTypeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…