Source file src/internal/buildcfg/exp_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 buildcfg
     6  
     7  import "testing"
     8  
     9  func TestSIMDImpliesSIMDStable(t *testing.T) {
    10  	for _, test := range []struct {
    11  		goexp      string
    12  		simd       bool
    13  		simdStable bool
    14  		err        bool
    15  	}{
    16  		{goexp: "", simdStable: true},
    17  		{goexp: "simdstable", simdStable: true},
    18  		{goexp: "simd", simd: true, simdStable: true},
    19  		{goexp: "simd,simdstable", simd: true, simdStable: true},
    20  		{goexp: "simdstable,nosimd", simdStable: true},
    21  		{goexp: "simd,nosimd", simdStable: true},
    22  		{goexp: "nosimd", simdStable: true},
    23  		{goexp: "nosimdstable"},
    24  		{goexp: "nosimdstable,simdstable", simdStable: true},
    25  		{goexp: "nosimdstable,nosimd"},
    26  		{goexp: "none"},
    27  		{goexp: "simd,nosimdstable", err: true},
    28  		{goexp: "nosimdstable,simd", err: true},
    29  		{goexp: "nosimdstable,none,simd", simd: true, simdStable: true},
    30  	} {
    31  		flags, err := ParseGOEXPERIMENT("linux", "amd64", test.goexp)
    32  		if test.err {
    33  			if err == nil {
    34  				t.Errorf("ParseGOEXPERIMENT(%q): want error, got nil", test.goexp)
    35  			}
    36  			continue
    37  		}
    38  		if err != nil {
    39  			t.Errorf("ParseGOEXPERIMENT(%q): %v", test.goexp, err)
    40  			continue
    41  		}
    42  		if flags.SIMD != test.simd || flags.SIMDStable != test.simdStable {
    43  			t.Errorf("ParseGOEXPERIMENT(%q): SIMD=%v, SIMDStable=%v; want %v, %v", test.goexp, flags.SIMD, flags.SIMDStable, test.simd, test.simdStable)
    44  		}
    45  	}
    46  }
    47  

View as plain text