@@ -117,6 +117,31 @@ func newFunc(
117
117
return fn
118
118
}
119
119
120
+ func TestErrConst (t * testing.T ) {
121
+ codeErrorTest (t , "./foo.gop:2:7 a redeclared in this block\n \t previous declaration at ./foo.gop:1:5" ,
122
+ func (pkg * gox.Package ) {
123
+ pkg .NewVarStart (position (1 , 5 ), nil , "a" ).Val (1 ).EndInit (1 )
124
+ pkg .NewConstStart (position (2 , 7 ), nil , "a" ).Val (2 ).EndInit (1 )
125
+ })
126
+ }
127
+
128
+ func TestErrNewVar (t * testing.T ) {
129
+ codeErrorTest (t , "./foo.gop:2:7 a redeclared in this block\n \t previous declaration at ./foo.gop:1:5" ,
130
+ func (pkg * gox.Package ) {
131
+ pkg .NewVarStart (position (1 , 5 ), nil , "a" ).Val (1 ).EndInit (1 )
132
+ pkg .NewVarStart (position (2 , 7 ), nil , "a" ).Val (2 ).EndInit (1 )
133
+ })
134
+ codeErrorTest (t , "./foo.gop:2:6 foo redeclared in this block\n \t previous declaration at ./foo.gop:1:5" ,
135
+ func (pkg * gox.Package ) {
136
+ var x * types.Var
137
+ pkg .Fset .AddFile ("./foo.gop" , 1 , 100 ).AddLine (10 )
138
+ pkg .NewFunc (nil , "main" , nil , nil , false ).BodyStart (pkg ).
139
+ NewAutoVar (position (1 , 5 ), "foo" , & x ).
140
+ NewAutoVar (position (2 , 6 ), "foo" , & x ).
141
+ End ()
142
+ })
143
+ }
144
+
120
145
func TestErrForRange (t * testing.T ) {
121
146
codeErrorTest (t , `./foo.gop:1:5 cannot assign type string to a (type int) in range` ,
122
147
func (pkg * gox.Package ) {
@@ -283,18 +308,6 @@ func TestErrLabel(t *testing.T) {
283
308
})
284
309
}
285
310
286
- func TestErrNewVar (t * testing.T ) {
287
- codeErrorTest (t , "./foo.gop:2:6 foo redeclared in this block\n \t previous declaration at ./foo.gop:1:5" ,
288
- func (pkg * gox.Package ) {
289
- var x * types.Var
290
- pkg .Fset .AddFile ("./foo.gop" , 1 , 100 ).AddLine (10 )
291
- pkg .NewFunc (nil , "main" , nil , nil , false ).BodyStart (pkg ).
292
- NewAutoVar (position (1 , 5 ), "foo" , & x ).
293
- NewAutoVar (position (2 , 6 ), "foo" , & x ).
294
- End ()
295
- })
296
- }
297
-
298
311
func _TestErrDefineVar (t * testing.T ) {
299
312
codeErrorTest (t , "foo redeclared in this block\n \t previous declaration at ./foo.gop:1" ,
300
313
func (pkg * gox.Package ) {
0 commit comments