diff options
author | Robert Griesemer <gri@golang.org> | 2021-04-05 16:06:18 -0700 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2021-04-07 05:19:36 +0000 |
commit | 836356bdaad92d525d65ce01e08305dfbeb7c1e6 (patch) | |
tree | 6c53cf1c298bc880fec2bac1be9b7b79c2557f4a /src/cmd/compile/internal/types2/check_test.go | |
parent | 8f1099b5850747cf61738606f6a3d1386f4458c6 (diff) | |
download | go-836356bdaad92d525d65ce01e08305dfbeb7c1e6.tar.gz go-836356bdaad92d525d65ce01e08305dfbeb7c1e6.zip |
cmd/compile/internal/types2: process errors in src order during testing
Follow-up on https://golang.org/cl/305573.
As a consequence, re-enable test case that caused problems with that CL.
Change-Id: Ibffee3f016f4885a55b8e527a5680dd437322209
Reviewed-on: https://go-review.googlesource.com/c/go/+/307216
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/check_test.go')
-rw-r--r-- | src/cmd/compile/internal/types2/check_test.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/cmd/compile/internal/types2/check_test.go b/src/cmd/compile/internal/types2/check_test.go index 2418c29a2f..331f0c7105 100644 --- a/src/cmd/compile/internal/types2/check_test.go +++ b/src/cmd/compile/internal/types2/check_test.go @@ -32,6 +32,7 @@ import ( "os" "path/filepath" "regexp" + "sort" "strings" "testing" @@ -150,6 +151,13 @@ func checkFiles(t *testing.T, filenames []string, goVersion string, colDelta uin return } + // sort errlist in source order + sort.Slice(errlist, func(i, j int) bool { + pi := unpackError(errlist[i]).Pos + pj := unpackError(errlist[j]).Pos + return pi.Cmp(pj) < 0 + }) + // collect expected errors errmap := make(map[string]map[uint][]syntax.Error) for _, filename := range filenames { @@ -165,7 +173,6 @@ func checkFiles(t *testing.T, filenames []string, goVersion string, colDelta uin } // match against found errors - // TODO(gri) sort err list to avoid mismatched when having multiple errors for _, err := range errlist { got := unpackError(err) @@ -205,9 +212,8 @@ func checkFiles(t *testing.T, filenames []string, goVersion string, colDelta uin // eliminate from list if n := len(list) - 1; n > 0 { - // not the last entry - swap in last element and shorten list by 1 - // TODO(gri) avoid changing the order of entries - list[index] = list[n] + // not the last entry - slide entries down (don't reorder) + copy(list[index:], list[index+1:]) filemap[line] = list[:n] } else { // last entry - remove list from filemap |