1 // Copyright 2023 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.
12 var tests = []struct {
16 {"//go:build linux && go1.60", 60},
17 {"//go:build ignore && go1.60", 60},
18 {"//go:build ignore || go1.60", -1},
19 {"//go:build go1.50 || (ignore && go1.60)", 50},
20 {"// +build go1.60,linux", 60},
21 {"// +build go1.60 linux", -1},
22 {"//go:build go1.50 && !go1.60", 50},
23 {"//go:build !go1.60", -1},
24 {"//go:build linux && go1.50 || darwin && go1.60", 50},
25 {"//go:build linux && go1.50 || !(!darwin || !go1.60)", 50},
28 func TestGoVersion(t *testing.T) {
29 for _, tt := range tests {
30 x, err := Parse(tt.in)
38 } else if tt.out > 0 {
39 want = fmt.Sprintf("go1.%d", tt.out)
42 t.Errorf("GoVersion(%q) = %q, want %q, nil", tt.in, v, want)