| 1 | package pass |
| 2 | |
| 3 | import ( |
| 4 | "reflect" |
| 5 | "testing" |
| 6 | |
| 7 | "github.com/mmcloughlin/avo/ir" |
| 8 | ) |
| 9 | |
| 10 | func TestRequiredISAExtensions(t *testing.T) { |
| 11 | f := ir.NewFunction("ISAs") |
| 12 | f.AddInstruction(&ir.Instruction{ISA: nil}) |
| 13 | f.AddInstruction(&ir.Instruction{ISA: []string{"B", "A"}}) |
| 14 | f.AddInstruction(&ir.Instruction{ISA: []string{"A", "C"}}) |
| 15 | |
| 16 | err := RequiredISAExtensions(f) |
| 17 | if err != nil { |
| 18 | t.Fatal(err) |
| 19 | } |
| 20 | |
| 21 | expect := []string{"A", "B", "C"} |
| 22 | if !reflect.DeepEqual(f.ISA, expect) { |
| 23 | t.FailNow() |
| 24 | } |
| 25 | } |