Source file src/simd/archsimd/_gen/simdgen/sve/integration_test.go

     1  // Copyright 2026 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package sve
     6  
     7  import (
     8  	"strings"
     9  	"testing"
    10  
    11  	"simd/archsimd/_gen/unify"
    12  )
    13  
    14  // TestAddUnifies checks that the loader's emitted ADD defs unify with the SVE op
    15  // and type definitions (in the parent simdgen directory) to yield concrete Go
    16  // API mappings.
    17  func TestAddUnifies(t *testing.T) {
    18  	defs := parse(t, addUnpred).emitAll()
    19  	if len(defs) == 0 {
    20  		t.Fatal("emitAll produced no defs")
    21  	}
    22  	inputs := []unify.Closure{unify.NewSum(defs...)}
    23  	for _, path := range []string{"../go_sve.yaml", "../types.yaml", "../categories.yaml"} {
    24  		cl, err := unify.ReadFile(path, unify.ReadOpts{})
    25  		if err != nil {
    26  			t.Fatalf("ReadFile %s: %v", path, err)
    27  		}
    28  		inputs = append(inputs, cl)
    29  	}
    30  	unified, err := unify.Unify(inputs...)
    31  	if err != nil {
    32  		t.Fatalf("Unify: %v", err)
    33  	}
    34  	var sawInt8s, sawUint8s bool
    35  	for v := range unified.All() {
    36  		if !v.Exact() {
    37  			continue
    38  		}
    39  		s := v.String()
    40  		if !strings.Contains(s, "Add") {
    41  			continue
    42  		}
    43  		sawInt8s = sawInt8s || strings.Contains(s, "Int8s")
    44  		sawUint8s = sawUint8s || strings.Contains(s, "Uint8s")
    45  	}
    46  	if !sawInt8s || !sawUint8s {
    47  		t.Errorf("want Int8s and Uint8s Add mappings, got int8s=%v uint8s=%v", sawInt8s, sawUint8s)
    48  	}
    49  }
    50  

View as plain text