From e9e58a4d49f518ab6ce3a2b2ed4efb34e022c1d4 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Wed, 14 Oct 2020 22:09:47 -0700 Subject: [dev.typeparams] cmd/compile/internal/syntax: fix printing of channel types Change-Id: I80a3ca77d0642711913c9584e70059e4ed668860 Reviewed-on: https://go-review.googlesource.com/c/go/+/262444 Trust: Robert Griesemer Reviewed-by: Matthew Dempsky --- src/cmd/compile/internal/syntax/printer_test.go | 26 ++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'src/cmd/compile/internal/syntax/printer_test.go') diff --git a/src/cmd/compile/internal/syntax/printer_test.go b/src/cmd/compile/internal/syntax/printer_test.go index c3b9aca229..cae2c40f6c 100644 --- a/src/cmd/compile/internal/syntax/printer_test.go +++ b/src/cmd/compile/internal/syntax/printer_test.go @@ -30,12 +30,28 @@ func TestPrint(t *testing.T) { } } +var stringTests = []string{ + "package p", + "package p; type _ int; type T1 = struct{}; type ( _ *struct{}; T2 = float32 )", + + // channels + "package p; type _ chan chan int", + "package p; type _ chan (<-chan int)", + "package p; type _ chan chan<- int", + + "package p; type _ <-chan chan int", + "package p; type _ <-chan <-chan int", + "package p; type _ <-chan chan<- int", + + "package p; type _ chan<- chan int", + "package p; type _ chan<- <-chan int", + "package p; type _ chan<- chan<- int", + + // TODO(gri) expand +} + func TestPrintString(t *testing.T) { - for _, want := range []string{ - "package p", - "package p; type _ = int; type T1 = struct{}; type ( _ = *struct{}; T2 = float32 )", - // TODO(gri) expand - } { + for _, want := range stringTests { ast, err := Parse(nil, strings.NewReader(want), nil, nil, 0) if err != nil { t.Error(err) -- cgit v1.2.3-54-g00ecf