Skip to content

Commit 97cc51e

Browse files
authored
Ensure all test code is valid and compiles (#200)
The code has always been valid enough to build a proper syntax tree but this will ensure that each folder actually builds and compiles without any errors as well. This is to ensure no diagnostics are missed due to invalid syntax.
1 parent 1c7344e commit 97cc51e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+552
-504
lines changed

testdata/src/default_config/assign/assign.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,17 @@ func assignAndCall() {
4949
t1.Fn()
5050
x := t1.Fn()
5151
t1.Fn()
52+
53+
_, _ = t2, x
5254
}
5355

5456
func closureInCall() {
5557
buf := &bytes.Buffer{}
56-
err := Fnc("buf", func() error {
58+
err := FnC("buf", func() error {
5759
return json.NewEncoder(buf).Encode("x")
5860
})
61+
62+
_ = err
5963
}
6064

6165
func assignAfterBlock() {
@@ -69,4 +73,6 @@ func assignAfterBlock() {
6973
func decl() {
7074
var x string
7175
y := "" // want `missing whitespace above this line \(invalid statement above assign\)`
76+
77+
_, _ = x, y
7278
}

testdata/src/default_config/assign/assign.go.golden

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,17 @@ func assignAndCall() {
5050
t1.Fn()
5151
x := t1.Fn()
5252
t1.Fn()
53+
54+
_, _ = t2, x
5355
}
5456

5557
func closureInCall() {
5658
buf := &bytes.Buffer{}
57-
err := Fnc("buf", func() error {
59+
err := FnC("buf", func() error {
5860
return json.NewEncoder(buf).Encode("x")
5961
})
62+
63+
_ = err
6064
}
6165

6266
func assignAfterBlock() {
@@ -72,4 +76,7 @@ func decl() {
7276
var x string
7377

7478
y := "" // want `missing whitespace above this line \(invalid statement above assign\)`
79+
80+
_, _ = x, y
7581
}
82+

testdata/src/default_config/branch/branch.go

Lines changed: 85 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -2,96 +2,97 @@ package testpkg
22

33
import "fmt"
44

5-
func fn1() {
6-
for range []int{} {
7-
if true {
8-
fmt.Println("")
9-
10-
continue
11-
}
12-
13-
if true {
14-
fmt.Println("")
15-
break
16-
}
17-
18-
if true {
19-
fmt.Println("")
20-
continue
21-
}
22-
23-
if true {
24-
fmt.Println("")
25-
fallthrough
5+
func validCases() {
6+
START:
7+
fmt.Println("start")
8+
9+
switch 1 {
10+
case 1:
11+
for range []int{} {
12+
if true {
13+
fmt.Println("")
14+
15+
continue
16+
}
17+
18+
if true {
19+
fmt.Println("")
20+
break
21+
}
22+
23+
if true {
24+
fmt.Println("")
25+
continue
26+
}
27+
28+
if true {
29+
fmt.Println("")
30+
goto START
31+
}
32+
33+
if false {
34+
fmt.Println("")
35+
fmt.Println("")
36+
fmt.Println("")
37+
38+
break
39+
}
40+
41+
if false {
42+
fmt.Println("")
43+
fmt.Println("")
44+
fmt.Println("")
45+
46+
continue
47+
}
48+
49+
if false {
50+
fmt.Println("")
51+
fmt.Println("")
52+
fmt.Println("")
53+
54+
goto START
55+
}
2656
}
2757

28-
if true {
29-
fmt.Println("")
30-
goto START
31-
}
32-
33-
if false {
34-
fmt.Println("")
35-
fmt.Println("")
36-
fmt.Println("")
37-
38-
break
39-
}
40-
41-
if false {
42-
fmt.Println("")
43-
fmt.Println("")
44-
fmt.Println("")
45-
46-
continue
47-
}
48-
49-
if false {
50-
fmt.Println("")
51-
fmt.Println("")
52-
fmt.Println("")
53-
54-
fallthrough
55-
}
56-
57-
if false {
58-
fmt.Println("")
59-
fmt.Println("")
60-
fmt.Println("")
61-
62-
goto START
63-
}
58+
fallthrough
59+
case 2:
6460
}
6561
}
6662

67-
func fn2() {
68-
for range []int{} {
69-
if true {
70-
fmt.Println("")
71-
fmt.Println("")
72-
fmt.Println("")
73-
break // want `missing whitespace above this line \(too many lines above branch\)`
74-
}
75-
76-
if true {
77-
fmt.Println("")
78-
fmt.Println("")
79-
fmt.Println("")
80-
continue // want `missing whitespace above this line \(too many lines above branch\)`
63+
func invalidCases() {
64+
START:
65+
fmt.Println("start")
66+
67+
switch 1 {
68+
case 1:
69+
for range []int{} {
70+
if true {
71+
fmt.Println("")
72+
fmt.Println("")
73+
fmt.Println("")
74+
break // want `missing whitespace above this line \(too many lines above branch\)`
75+
}
76+
77+
if true {
78+
fmt.Println("")
79+
fmt.Println("")
80+
fmt.Println("")
81+
continue // want `missing whitespace above this line \(too many lines above branch\)`
82+
}
83+
84+
if true {
85+
fmt.Println("")
86+
fmt.Println("")
87+
fmt.Println("")
88+
goto START // want `missing whitespace above this line \(too many lines above branch\)`
89+
}
8190
}
8291

83-
if true {
84-
fmt.Println("")
85-
fmt.Println("")
86-
fmt.Println("")
87-
fallthrough // want `missing whitespace above this line \(too many lines above branch\)`
88-
}
89-
90-
if true {
91-
fmt.Println("")
92-
fmt.Println("")
93-
fmt.Println("")
94-
goto START // want `missing whitespace above this line \(too many lines above branch\)`
95-
}
92+
fmt.Println("")
93+
fmt.Println("")
94+
fmt.Println("")
95+
fallthrough // want `missing whitespace above this line \(too many lines above branch\)`
96+
case 2:
9697
}
9798
}

0 commit comments

Comments
 (0)