1
2
3
4
5 package specgen
6
7 import (
8 "simd/archsimd/_gen/specgen/specexpr"
9 "testing"
10 )
11
12 func TestIndex(t *testing.T) {
13 vecType := specexpr.Vector{Elem: specexpr.Basic{Base: "int", Bits: 32}, Width: specexpr.Int(128)}
14 f1 := &Func{
15 Name: "Add",
16 Recv: Arg{Name: "x", Type: vecType},
17 }
18 f2 := &Func{
19 Name: "GlobalFunc",
20 }
21
22 idx := NewIndex([]*Func{f1, f2})
23 if idx.Len() != 2 {
24 t.Fatalf("expected Len 2, got %d", idx.Len())
25 }
26
27 if got := idx.Lookup("Int32x4", "Add"); got != f1 {
28 t.Errorf("Lookup(Int32x4, Add) = %v, want %v", got, f1)
29 }
30 if got := idx.Lookup("", "GlobalFunc"); got != f2 {
31 t.Errorf("Lookup('', GlobalFunc) = %v, want %v", got, f2)
32 }
33 if got := idx.Lookup("Int32x4", "Missing"); got != nil {
34 t.Errorf("Lookup(Int32x4, Missing) = %v, want nil", got)
35 }
36 }
37
View as plain text