aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/syntax/parser_test.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2020-10-10 17:02:15 -0700
committerRobert Griesemer <gri@golang.org>2020-10-13 04:39:31 +0000
commit7668f02dec44690ee61722f08b2d80b5b0c5eccd (patch)
treea494c14ae85012046c7bc58634574bfa2b19c20c /src/cmd/compile/internal/syntax/parser_test.go
parentb627988b0ca748a73867ba5fc4cfc70031c028d2 (diff)
downloadgo-7668f02dec44690ee61722f08b2d80b5b0c5eccd.tar.gz
go-7668f02dec44690ee61722f08b2d80b5b0c5eccd.zip
[dev.typeparams] cmd/compile/internal/syntax: add type parameter tests
The file endings are not .go so that gofmt leaves these files alone. They are also not .src to distinguish them from regular go source tests. Change-Id: I741f5c037bad1ea9d6f7fda3673487d0be631350 Reviewed-on: https://go-review.googlesource.com/c/go/+/261219 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/syntax/parser_test.go')
-rw-r--r--src/cmd/compile/internal/syntax/parser_test.go21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/syntax/parser_test.go b/src/cmd/compile/internal/syntax/parser_test.go
index f1c5433b40..e270879739 100644
--- a/src/cmd/compile/internal/syntax/parser_test.go
+++ b/src/cmd/compile/internal/syntax/parser_test.go
@@ -29,7 +29,24 @@ func TestParse(t *testing.T) {
ParseFile(*src_, func(err error) { t.Error(err) }, nil, 0)
}
-func TestStdLib(t *testing.T) {
+func TestParseGo2(t *testing.T) {
+ dir := filepath.Join(testdata, "go2")
+ list, err := ioutil.ReadDir(dir)
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, fi := range list {
+ name := fi.Name()
+ if !fi.IsDir() && !strings.HasPrefix(name, ".") {
+ ParseFile(filepath.Join(dir, name), func(err error) { t.Error(err) }, nil, AllowGenerics)
+ }
+ }
+}
+
+func TestStdLib(t *testing.T) { testStdLib(t, 0) }
+func TestStdLibGeneric(t *testing.T) { testStdLib(t, AllowGenerics) }
+
+func testStdLib(t *testing.T, mode Mode) {
if testing.Short() {
t.Skip("skipping test in short mode")
}
@@ -68,7 +85,7 @@ func TestStdLib(t *testing.T) {
if debug {
fmt.Printf("parsing %s\n", filename)
}
- ast, err := ParseFile(filename, nil, nil, 0)
+ ast, err := ParseFile(filename, nil, nil, mode)
if err != nil {
t.Error(err)
return