...
1
2
3
4
5
6
7
8 package syntax
9
10 import (
11 "strings"
12 "testing"
13 )
14
15 func TestIssue67866(t *testing.T) {
16 var tests = []string{
17 "package p; var _ = T{@0: 0}",
18 "package p; var _ = T{@1 + 2: 0}",
19 "package p; var _ = T{@x[i]: 0}",
20 "package p; var _ = T{@f(1, 2, 3): 0}",
21 "package p; var _ = T{@a + f(b) + <-ch: 0}",
22 }
23
24 for _, src := range tests {
25
26 i := strings.Index(src, "@")
27 if i < 0 {
28 t.Errorf("%s: invalid test case (missing @)", src)
29 continue
30 }
31 src = src[:i] + src[i+1:]
32 want := colbase + uint(i)
33
34 f, err := Parse(nil, strings.NewReader(src), nil, nil, 0)
35 if err != nil {
36 t.Errorf("%s: %v", src, err)
37 continue
38 }
39
40
41 Inspect(f, func(n Node) bool {
42 _, ok := n.(*KeyValueExpr)
43 if ok {
44 if got := StartPos(n).Col(); got != want {
45 t.Errorf("%s: got col = %d, want %d", src, got, want)
46 }
47 }
48 return !ok
49 })
50 }
51 }
52
View as plain text