test asmtest with instruction list
This commit is contained in:
@@ -31,7 +31,7 @@ func NewLoaderFromDataDir(dir string) *Loader {
|
||||
}
|
||||
}
|
||||
|
||||
func (l *Loader) Load() ([]*inst.Instruction, error) {
|
||||
func (l *Loader) Load() ([]inst.Instruction, error) {
|
||||
if err := l.init(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -63,9 +63,9 @@ func (l *Loader) Load() ([]*inst.Instruction, error) {
|
||||
}
|
||||
|
||||
// Convert to a slice, sorted by opcode.
|
||||
is := make([]*inst.Instruction, 0, len(im))
|
||||
is := make([]inst.Instruction, 0, len(im))
|
||||
for _, i := range im {
|
||||
is = append(is, i)
|
||||
is = append(is, *i)
|
||||
}
|
||||
|
||||
sort.Slice(is, func(i, j int) bool {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package load_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"testing"
|
||||
|
||||
"github.com/mmcloughlin/avo/internal/gen"
|
||||
@@ -10,7 +9,7 @@ import (
|
||||
"github.com/mmcloughlin/avo/internal/test"
|
||||
)
|
||||
|
||||
func Load(t *testing.T) []*inst.Instruction {
|
||||
func Load(t *testing.T) []inst.Instruction {
|
||||
t.Helper()
|
||||
l := load.NewLoaderFromDataDir("testdata")
|
||||
is, err := l.Load()
|
||||
@@ -22,10 +21,10 @@ func Load(t *testing.T) []*inst.Instruction {
|
||||
|
||||
func TestAssembles(t *testing.T) {
|
||||
is := Load(t)
|
||||
|
||||
g := &gen.LoaderTest{}
|
||||
var buf bytes.Buffer
|
||||
g.Generate(&buf, is)
|
||||
|
||||
test.Assembles(t, buf.Bytes())
|
||||
g := gen.NewAsmTest(gen.Config{})
|
||||
b, err := g.Generate(is)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
test.Assembles(t, b)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user