-
Notifications
You must be signed in to change notification settings - Fork 17.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Forgot to 'git add' this test written as part of CL 359314. For #41184. Change-Id: I2ebd48fd62a2053c8b16e5a8c48c1e11d1b86d5b Reviewed-on: https://go-review.googlesource.com/c/go/+/366894 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
- Loading branch information
Showing
2 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2021 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
var buildParserTests = []struct { | ||
x string | ||
matched bool | ||
err error | ||
}{ | ||
{"gc", true, nil}, | ||
{"gccgo", false, nil}, | ||
{"!gc", false, nil}, | ||
{"gc && gccgo", false, nil}, | ||
{"gc || gccgo", true, nil}, | ||
{"gc || (gccgo && !gccgo)", true, nil}, | ||
{"gc && (gccgo || !gccgo)", true, nil}, | ||
{"!(gc && (gccgo || !gccgo))", false, nil}, | ||
{"gccgo || gc", true, nil}, | ||
{"!(!(!(gccgo || gc)))", false, nil}, | ||
{"compiler_bootstrap", false, nil}, | ||
{"cmd_go_bootstrap", true, nil}, | ||
{"syntax(error", false, fmt.Errorf("parsing //go:build line: unexpected (")}, | ||
{"(gc", false, fmt.Errorf("parsing //go:build line: missing )")}, | ||
{"gc gc", false, fmt.Errorf("parsing //go:build line: unexpected tag")}, | ||
{"(gc))", false, fmt.Errorf("parsing //go:build line: unexpected )")}, | ||
} | ||
|
||
func TestBuildParser(t *testing.T) { | ||
for _, tt := range buildParserTests { | ||
matched, err := matchexpr(tt.x) | ||
if matched != tt.matched || !reflect.DeepEqual(err, tt.err) { | ||
t.Errorf("matchexpr(%q) = %v, %v; want %v, %v", tt.x, matched, err, tt.matched, tt.err) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters