Files
wehub-resource-sync c4536f7e05
CI / test (push) Failing after 1s
CI / macOS amd64 (push) Has been cancelled
CI / macOS arm64 (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:30:31 +08:00

36 lines
677 B
Go

package wasmobj
import (
"path/filepath"
"regexp"
"testing"
"loov.dev/lensm/internal/disasm"
)
var rxByteInst = regexp.MustCompile(`^BYTE 0x[0-9a-f]{2}$`)
func TestLoadFormatsBytes(t *testing.T) {
file, err := Load(filepath.Join("..", "..", "testdata", "c-wasm", "example.wasm"))
if err != nil {
t.Fatal(err)
}
for _, fn := range file.funcs {
code, err := fn.Load(disasm.Options{})
if err != nil {
t.Fatal(err)
}
if len(code.Insts) == 0 {
continue
}
for _, inst := range code.Insts {
if !rxByteInst.MatchString(inst.Text) {
t.Fatalf("instruction text = %q", inst.Text)
}
}
return
}
t.Fatal("no wasm function with body found")
}