wasmtest

package
v0.19.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Call

func Call[R types.Param[R], T any](fn wazergo.Function[T], ctx context.Context, module api.Module, this T, args ...types.Result) (ret R)

Types

type Bytes

type Bytes types.Bytes

Bytes is an extension of the types.Bytes type which adds the ability to treat those values as results, so they can be passed as argument to Call* functions in tests. The content of the byte slice is copied to the WebAssembly module memory, starting at address zero in each invocation of Call* functions. This would be really unsafe to do in a production applicaiton, which is why the feature is only made available to unit tests.

func (Bytes) FormatValue

func (arg Bytes) FormatValue(w io.Writer, memory api.Memory, stack []uint64)

func (Bytes) LoadValue

func (arg Bytes) LoadValue(memory api.Memory, stack []uint64) Bytes

func (Bytes) StoreValue

func (arg Bytes) StoreValue(memory api.Memory, stack []uint64)

func (Bytes) ValueTypes

func (arg Bytes) ValueTypes() []api.ValueType

type Module

type Module struct {
	api.Module // TODO: implement more features of the interface
	// contains filtered or unexported fields
}

Module is an implementation of wazero's api.Module interface intended to be used as a stub in tests. The main feature is the ability to define a memory that the module will be exposing as its exported "memory".

func NewModule

func NewModule(name string, opts ...ModuleOption) *Module

NewModule constructs a Module instance with the given name and configuration options.

func (*Module) ExportedMemory

func (mod *Module) ExportedMemory(name string) api.Memory

func (*Module) Memory

func (mod *Module) Memory() api.Memory

func (*Module) Name

func (mod *Module) Name() string

type ModuleOption

type ModuleOption = wazergo.Option[*Module]

ModuleOption represents configuration options for the Module type.

func Memory

func Memory(memory api.Memory) ModuleOption

Memory sets the memory of a Module instance.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL