-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathissues_test.go
51 lines (44 loc) · 1.17 KB
/
issues_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright 2024 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.
// This file holds test cases for individual issues
// for which there is (currently) no better location.
package syntax
import (
"strings"
"testing"
)
func TestIssue67866(t *testing.T) {
var tests = []string{
"package p; var _ = T{@0: 0}",
"package p; var _ = T{@1 + 2: 0}",
"package p; var _ = T{@x[i]: 0}",
"package p; var _ = T{@f(1, 2, 3): 0}",
"package p; var _ = T{@a + f(b) + <-ch: 0}",
}
for _, src := range tests {
// identify column position of @ and remove it from src
i := strings.Index(src, "@")
if i < 0 {
t.Errorf("%s: invalid test case (missing @)", src)
continue
}
src = src[:i] + src[i+1:]
want := colbase + uint(i)
f, err := Parse(nil, strings.NewReader(src), nil, nil, 0)
if err != nil {
t.Errorf("%s: %v", src, err)
continue
}
// locate KeyValueExpr
Inspect(f, func(n Node) bool {
_, ok := n.(*KeyValueExpr)
if ok {
if got := StartPos(n).Col(); got != want {
t.Errorf("%s: got col = %d, want %d", src, got, want)
}
}
return !ok
})
}
}