2020-01-19 16:45:09 -08:00
|
|
|
package pass
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"reflect"
|
|
|
|
|
"testing"
|
|
|
|
|
|
2026-03-06 20:14:02 +00:00
|
|
|
"sources.truenas.cloud/code/avo/ir"
|
2020-01-19 16:45:09 -08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestRequiredISAExtensions(t *testing.T) {
|
|
|
|
|
f := ir.NewFunction("ISAs")
|
|
|
|
|
f.AddInstruction(&ir.Instruction{ISA: nil})
|
|
|
|
|
f.AddInstruction(&ir.Instruction{ISA: []string{"B", "A"}})
|
|
|
|
|
f.AddInstruction(&ir.Instruction{ISA: []string{"A", "C"}})
|
|
|
|
|
|
|
|
|
|
err := RequiredISAExtensions(f)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
expect := []string{"A", "B", "C"}
|
|
|
|
|
if !reflect.DeepEqual(f.ISA, expect) {
|
|
|
|
|
t.FailNow()
|
|
|
|
|
}
|
|
|
|
|
}
|