Debian Codegraph @

gopls/internal/test/marker/testdata/codeaction/addtest.txt

raw
1 This test checks the behavior of the 'add test for FUNC' code action.
2
3 -- flags --
4 -ignore_extra_diags
5
6 -- go.mod --
7 module golang.org/lsptests/addtest
8
9 go 1.24
10
11 -- copyrightandbuildconstraint/copyrightandbuildconstraint.go --
12 // Copyright 2020 The Go Authors. All rights reserved.
13 // Use of this source code is governed by a BSD-style
14 // license that can be found in the LICENSE file.
15
16 //go:build go1.18
17
18 // Package main is for lsp test.
19 package main
20
21 func Foo(in string) string {return in} //@codeaction("Foo", "source.addTest", edit=with_copyright_build_constraint)
22
23 -- @with_copyright_build_constraint/copyrightandbuildconstraint/copyrightandbuildconstraint_test.go --
24 @@ -0,0 +1,32 @@
25 +// Copyright 2020 The Go Authors. All rights reserved.
26 +// Use of this source code is governed by a BSD-style
27 +// license that can be found in the LICENSE file.
28 +
29 +//go:build go1.18
30 +
31 +package main_test
32 +
33 +import(
34 + "golang.org/lsptests/addtest/copyrightandbuildconstraint"
35 + "testing"
36 +)
37 +
38 +func TestFoo(t *testing.T) {
39 + tests := []struct {
40 + name string // description of this test case
41 + // Named input parameters for target function.
42 + in string
43 + want string
44 + }{
45 + // TODO: Add test cases.
46 + }
47 + for _, tt := range tests {
48 + t.Run(tt.name, func(t *testing.T) {
49 + got := main.Foo(tt.in)
50 + // TODO: update the condition below to compare got with tt.want.
51 + if true {
52 + t.Errorf("Foo() = %v, want %v", got, tt.want)
53 + }
54 + })
55 + }
56 +}
57 -- buildconstraint/buildconstraint.go --
58 //go:build go1.18
59
60 // Package copyright is for lsp test.
61 package copyright
62
63 func Foo(in string) string {return in} //@codeaction("Foo", "source.addTest", edit=with_build_constraint)
64
65 -- @with_build_constraint/buildconstraint/buildconstraint_test.go --
66 @@ -0,0 +1,28 @@
67 +//go:build go1.18
68 +
69 +package copyright_test
70 +
71 +import(
72 + "golang.org/lsptests/addtest/buildconstraint"
73 + "testing"
74 +)
75 +
76 +func TestFoo(t *testing.T) {
77 + tests := []struct {
78 + name string // description of this test case
79 + // Named input parameters for target function.
80 + in string
81 + want string
82 + }{
83 + // TODO: Add test cases.
84 + }
85 + for _, tt := range tests {
86 + t.Run(tt.name, func(t *testing.T) {
87 + got := copyright.Foo(tt.in)
88 + // TODO: update the condition below to compare got with tt.want.
89 + if true {
90 + t.Errorf("Foo() = %v, want %v", got, tt.want)
91 + }
92 + })
93 + }
94 +}
95 -- missingtestfile/missingtestfile.go --
96 package main
97
98 type Bar struct {}
99
100 type foo struct {}
101
102 func ExportedFunction(in string) string {return in} //@codeaction("ExportedFunction", "source.addTest", edit=missing_test_file_exported_function)
103
104 func UnexportedInputParam(in string, f foo) string {return in} //@codeaction("UnexportedInputParam", "source.addTest", edit=missing_test_file_function_unexported_input)
105
106 func unexportedFunction(in string) string {return in} //@codeaction("unexportedFunction", "source.addTest", edit=missing_test_file_unexported_function)
107
108 func (*Bar) ExportedMethod(in string) string {return in} //@codeaction("ExportedMethod", "source.addTest", edit=missing_test_file_exported_recv_exported_method)
109
110 func (*Bar) UnexportedInputParam(in string, f foo) string {return in} //@codeaction("UnexportedInputParam", "source.addTest", edit=missing_test_file_method_unexported_input)
111
112 func (*foo) ExportedMethod(in string) string {return in} //@codeaction("ExportedMethod", "source.addTest", edit=missing_test_file_unexported_recv)
113
114 -- @missing_test_file_exported_function/missingtestfile/missingtestfile_test.go --
115 @@ -0,0 +1,26 @@
116 +package main_test
117 +
118 +import(
119 + "golang.org/lsptests/addtest/missingtestfile"
120 + "testing"
121 +)
122 +
123 +func TestExportedFunction(t *testing.T) {
124 + tests := []struct {
125 + name string // description of this test case
126 + // Named input parameters for target function.
127 + in string
128 + want string
129 + }{
130 + // TODO: Add test cases.
131 + }
132 + for _, tt := range tests {
133 + t.Run(tt.name, func(t *testing.T) {
134 + got := main.ExportedFunction(tt.in)
135 + // TODO: update the condition below to compare got with tt.want.
136 + if true {
137 + t.Errorf("ExportedFunction() = %v, want %v", got, tt.want)
138 + }
139 + })
140 + }
141 +}
142 -- @missing_test_file_exported_recv_exported_method/missingtestfile/missingtestfile_test.go --
143 @@ -0,0 +1,28 @@
144 +package main_test
145 +
146 +import(
147 + "golang.org/lsptests/addtest/missingtestfile"
148 + "testing"
149 +)
150 +
151 +func TestBar_ExportedMethod(t *testing.T) {
152 + tests := []struct {
153 + name string // description of this test case
154 + // Named input parameters for target function.
155 + in string
156 + want string
157 + }{
158 + // TODO: Add test cases.
159 + }
160 + for _, tt := range tests {
161 + t.Run(tt.name, func(t *testing.T) {
162 + // TODO: construct the receiver type.
163 + var b main.Bar
164 + got := b.ExportedMethod(tt.in)
165 + // TODO: update the condition below to compare got with tt.want.
166 + if true {
167 + t.Errorf("ExportedMethod() = %v, want %v", got, tt.want)
168 + }
169 + })
170 + }
171 +}
172 -- @missing_test_file_function_unexported_input/missingtestfile/missingtestfile_test.go --
173 @@ -0,0 +1,24 @@
174 +package main
175 +
176 +import "testing"
177 +
178 +func TestUnexportedInputParam(t *testing.T) {
179 + tests := []struct {
180 + name string // description of this test case
181 + // Named input parameters for target function.
182 + in string
183 + f foo
184 + want string
185 + }{
186 + // TODO: Add test cases.
187 + }
188 + for _, tt := range tests {
189 + t.Run(tt.name, func(t *testing.T) {
190 + got := UnexportedInputParam(tt.in, tt.f)
191 + // TODO: update the condition below to compare got with tt.want.
192 + if true {
193 + t.Errorf("UnexportedInputParam() = %v, want %v", got, tt.want)
194 + }
195 + })
196 + }
197 +}
198 -- @missing_test_file_method_unexported_input/missingtestfile/missingtestfile_test.go --
199 @@ -0,0 +1,26 @@
200 +package main
201 +
202 +import "testing"
203 +
204 +func TestBar_UnexportedInputParam(t *testing.T) {
205 + tests := []struct {
206 + name string // description of this test case
207 + // Named input parameters for target function.
208 + in string
209 + f foo
210 + want string
211 + }{
212 + // TODO: Add test cases.
213 + }
214 + for _, tt := range tests {
215 + t.Run(tt.name, func(t *testing.T) {
216 + // TODO: construct the receiver type.
217 + var b Bar
218 + got := b.UnexportedInputParam(tt.in, tt.f)
219 + // TODO: update the condition below to compare got with tt.want.
220 + if true {
221 + t.Errorf("UnexportedInputParam() = %v, want %v", got, tt.want)
222 + }
223 + })
224 + }
225 +}
226 -- @missing_test_file_unexported_function/missingtestfile/missingtestfile_test.go --
227 @@ -0,0 +1,23 @@
228 +package main
229 +
230 +import "testing"
231 +
232 +func Test_unexportedFunction(t *testing.T) {
233 + tests := []struct {
234 + name string // description of this test case
235 + // Named input parameters for target function.
236 + in string
237 + want string
238 + }{
239 + // TODO: Add test cases.
240 + }
241 + for _, tt := range tests {
242 + t.Run(tt.name, func(t *testing.T) {
243 + got := unexportedFunction(tt.in)
244 + // TODO: update the condition below to compare got with tt.want.
245 + if true {
246 + t.Errorf("unexportedFunction() = %v, want %v", got, tt.want)
247 + }
248 + })
249 + }
250 +}
251 -- @missing_test_file_unexported_recv/missingtestfile/missingtestfile_test.go --
252 @@ -0,0 +1,25 @@
253 +package main
254 +
255 +import "testing"
256 +
257 +func Test_foo_ExportedMethod(t *testing.T) {
258 + tests := []struct {
259 + name string // description of this test case
260 + // Named input parameters for target function.
261 + in string
262 + want string
263 + }{
264 + // TODO: Add test cases.
265 + }
266 + for _, tt := range tests {
267 + t.Run(tt.name, func(t *testing.T) {
268 + // TODO: construct the receiver type.
269 + var f foo
270 + got := f.ExportedMethod(tt.in)
271 + // TODO: update the condition below to compare got with tt.want.
272 + if true {
273 + t.Errorf("ExportedMethod() = %v, want %v", got, tt.want)
274 + }
275 + })
276 + }
277 +}
278 -- xpackagetestfile/xpackagetestfile.go --
279 package main
280
281 func ExportedFunction(in string) string {return in} //@codeaction("ExportedFunction", "source.addTest", edit=xpackage_exported_function)
282 func unexportedFunction(in string) string {return in} //@codeaction("unexportedFunction", "source.addTest", edit=xpackage_unexported_function)
283
284 type Bar struct {}
285
286 func (*Bar) ExportedMethod(in string) string {return in} //@codeaction("ExportedMethod", "source.addTest", edit=xpackage_exported_recv_exported_method)
287 func (*Bar) unexportedMethod(in string) string {return in} //@codeaction("unexportedMethod", "source.addTest", edit=xpackage_exported_recv_unexported_method)
288
289 type foo struct {}
290
291 func (*foo) ExportedMethod(in string) string {return in} //@codeaction("ExportedMethod", "source.addTest", edit=xpackage_unexported_recv_exported_method)
292 func (*foo) unexportedMethod(in string) string {return in} //@codeaction("unexportedMethod", "source.addTest", edit=xpackage_unexported_recv_unexported_method)
293
294 -- xpackagetestfile/xpackagetestfile_test.go --
295 package main
296
297 -- @xpackage_exported_function/xpackagetestfile/xpackagetestfile_test.go --
298 @@ -3 +3,22 @@
299 +import "testing"
300 +
301 +
302 +func TestExportedFunction(t *testing.T) {
303 + tests := []struct {
304 + name string // description of this test case
305 + // Named input parameters for target function.
306 + in string
307 + want string
308 + }{
309 + // TODO: Add test cases.
310 + }
311 + for _, tt := range tests {
312 + t.Run(tt.name, func(t *testing.T) {
313 + got := ExportedFunction(tt.in)
314 + // TODO: update the condition below to compare got with tt.want.
315 + if true {
316 + t.Errorf("ExportedFunction() = %v, want %v", got, tt.want)
317 + }
318 + })
319 + }
320 +}
321 -- @xpackage_unexported_function/xpackagetestfile/xpackagetestfile_test.go --
322 @@ -3 +3,22 @@
323 +import "testing"
324 +
325 +
326 +func Test_unexportedFunction(t *testing.T) {
327 + tests := []struct {
328 + name string // description of this test case
329 + // Named input parameters for target function.
330 + in string
331 + want string
332 + }{
333 + // TODO: Add test cases.
334 + }
335 + for _, tt := range tests {
336 + t.Run(tt.name, func(t *testing.T) {
337 + got := unexportedFunction(tt.in)
338 + // TODO: update the condition below to compare got with tt.want.
339 + if true {
340 + t.Errorf("unexportedFunction() = %v, want %v", got, tt.want)
341 + }
342 + })
343 + }
344 +}
345 -- @xpackage_exported_recv_exported_method/xpackagetestfile/xpackagetestfile_test.go --
346 @@ -3 +3,24 @@
347 +import "testing"
348 +
349 +
350 +func TestBar_ExportedMethod(t *testing.T) {
351 + tests := []struct {
352 + name string // description of this test case
353 + // Named input parameters for target function.
354 + in string
355 + want string
356 + }{
357 + // TODO: Add test cases.
358 + }
359 + for _, tt := range tests {
360 + t.Run(tt.name, func(t *testing.T) {
361 + // TODO: construct the receiver type.
362 + var b Bar
363 + got := b.ExportedMethod(tt.in)
364 + // TODO: update the condition below to compare got with tt.want.
365 + if true {
366 + t.Errorf("ExportedMethod() = %v, want %v", got, tt.want)
367 + }
368 + })
369 + }
370 +}
371 -- @xpackage_exported_recv_unexported_method/xpackagetestfile/xpackagetestfile_test.go --
372 @@ -3 +3,24 @@
373 +import "testing"
374 +
375 +
376 +func TestBar_unexportedMethod(t *testing.T) {
377 + tests := []struct {
378 + name string // description of this test case
379 + // Named input parameters for target function.
380 + in string
381 + want string
382 + }{
383 + // TODO: Add test cases.
384 + }
385 + for _, tt := range tests {
386 + t.Run(tt.name, func(t *testing.T) {
387 + // TODO: construct the receiver type.
388 + var b Bar
389 + got := b.unexportedMethod(tt.in)
390 + // TODO: update the condition below to compare got with tt.want.
391 + if true {
392 + t.Errorf("unexportedMethod() = %v, want %v", got, tt.want)
393 + }
394 + })
395 + }
396 +}
397 -- @xpackage_unexported_recv_exported_method/xpackagetestfile/xpackagetestfile_test.go --
398 @@ -3 +3,24 @@
399 +import "testing"
400 +
401 +
402 +func Test_foo_ExportedMethod(t *testing.T) {
403 + tests := []struct {
404 + name string // description of this test case
405 + // Named input parameters for target function.
406 + in string
407 + want string
408 + }{
409 + // TODO: Add test cases.
410 + }
411 + for _, tt := range tests {
412 + t.Run(tt.name, func(t *testing.T) {
413 + // TODO: construct the receiver type.
414 + var f foo
415 + got := f.ExportedMethod(tt.in)
416 + // TODO: update the condition below to compare got with tt.want.
417 + if true {
418 + t.Errorf("ExportedMethod() = %v, want %v", got, tt.want)
419 + }
420 + })
421 + }
422 +}
423 -- @xpackage_unexported_recv_unexported_method/xpackagetestfile/xpackagetestfile_test.go --
424 @@ -3 +3,24 @@
425 +import "testing"
426 +
427 +
428 +func Test_foo_unexportedMethod(t *testing.T) {
429 + tests := []struct {
430 + name string // description of this test case
431 + // Named input parameters for target function.
432 + in string
433 + want string
434 + }{
435 + // TODO: Add test cases.
436 + }
437 + for _, tt := range tests {
438 + t.Run(tt.name, func(t *testing.T) {
439 + // TODO: construct the receiver type.
440 + var f foo
441 + got := f.unexportedMethod(tt.in)
442 + // TODO: update the condition below to compare got with tt.want.
443 + if true {
444 + t.Errorf("unexportedMethod() = %v, want %v", got, tt.want)
445 + }
446 + })
447 + }
448 +}
449 -- aliasreceiver/aliasreceiver.go --
450 package main
451
452 type bar0 struct {}
453 type bar1 = bar0
454 type Bar = bar1
455
456 func (*Bar) ExportedMethod(in string) string {return in} //@codeaction("ExportedMethod", "source.addTest", edit=pointer_receiver_exported_method)
457 func (*Bar) unexportedMethod(in string) string {return in} //@codeaction("unexportedMethod", "source.addTest", edit=pointer_receiver_unexported_method)
458
459 type foo0 struct {}
460 type foo1 = foo0
461 type foo = foo1
462
463 func (foo) ExportedMethod(in string) string {return in} //@codeaction("ExportedMethod", "source.addTest", edit=alias_receiver_exported_method)
464 func (foo) unexportedMethod(in string) string {return in} //@codeaction("unexportedMethod", "source.addTest", edit=alias_receiver_unexported_method)
465
466 type baz0 struct{}
467 type baz1 = baz0
468 type baz = baz1
469
470 func newBaz0() baz0 {return baz0{}}
471
472 func (baz) method(in string) string {return in} //@codeaction("method", "source.addTest", edit=alias_constructor_on_underlying_type)
473
474 type qux0 struct{}
475 type qux1 = qux0
476 type qux2 = qux1
477 type Qux = *qux2
478
479 func newQux1() (qux1, error) {return qux1{}, nil}
480
481 func (Qux) method(in string) string {return in} //@codeaction("method", "source.addTest", edit=alias_constructor_on_different_alias_type)
482
483 -- aliasreceiver/aliasreceiver_test.go --
484 package main
485
486 -- @pointer_receiver_exported_method/aliasreceiver/aliasreceiver_test.go --
487 @@ -3 +3,24 @@
488 +import "testing"
489 +
490 +
491 +func TestBar_ExportedMethod(t *testing.T) {
492 + tests := []struct {
493 + name string // description of this test case
494 + // Named input parameters for target function.
495 + in string
496 + want string
497 + }{
498 + // TODO: Add test cases.
499 + }
500 + for _, tt := range tests {
501 + t.Run(tt.name, func(t *testing.T) {
502 + // TODO: construct the receiver type.
503 + var b Bar
504 + got := b.ExportedMethod(tt.in)
505 + // TODO: update the condition below to compare got with tt.want.
506 + if true {
507 + t.Errorf("ExportedMethod() = %v, want %v", got, tt.want)
508 + }
509 + })
510 + }
511 +}
512 -- @pointer_receiver_unexported_method/aliasreceiver/aliasreceiver_test.go --
513 @@ -3 +3,24 @@
514 +import "testing"
515 +
516 +
517 +func TestBar_unexportedMethod(t *testing.T) {
518 + tests := []struct {
519 + name string // description of this test case
520 + // Named input parameters for target function.
521 + in string
522 + want string
523 + }{
524 + // TODO: Add test cases.
525 + }
526 + for _, tt := range tests {
527 + t.Run(tt.name, func(t *testing.T) {
528 + // TODO: construct the receiver type.
529 + var b Bar
530 + got := b.unexportedMethod(tt.in)
531 + // TODO: update the condition below to compare got with tt.want.
532 + if true {
533 + t.Errorf("unexportedMethod() = %v, want %v", got, tt.want)
534 + }
535 + })
536 + }
537 +}
538 -- @alias_receiver_exported_method/aliasreceiver/aliasreceiver_test.go --
539 @@ -3 +3,24 @@
540 +import "testing"
541 +
542 +
543 +func Test_foo_ExportedMethod(t *testing.T) {
544 + tests := []struct {
545 + name string // description of this test case
546 + // Named input parameters for target function.
547 + in string
548 + want string
549 + }{
550 + // TODO: Add test cases.
551 + }
552 + for _, tt := range tests {
553 + t.Run(tt.name, func(t *testing.T) {
554 + // TODO: construct the receiver type.
555 + var f foo
556 + got := f.ExportedMethod(tt.in)
557 + // TODO: update the condition below to compare got with tt.want.
558 + if true {
559 + t.Errorf("ExportedMethod() = %v, want %v", got, tt.want)
560 + }
561 + })
562 + }
563 +}
564 -- @alias_receiver_unexported_method/aliasreceiver/aliasreceiver_test.go --
565 @@ -3 +3,24 @@
566 +import "testing"
567 +
568 +
569 +func Test_foo_unexportedMethod(t *testing.T) {
570 + tests := []struct {
571 + name string // description of this test case
572 + // Named input parameters for target function.
573 + in string
574 + want string
575 + }{
576 + // TODO: Add test cases.
577 + }
578 + for _, tt := range tests {
579 + t.Run(tt.name, func(t *testing.T) {
580 + // TODO: construct the receiver type.
581 + var f foo
582 + got := f.unexportedMethod(tt.in)
583 + // TODO: update the condition below to compare got with tt.want.
584 + if true {
585 + t.Errorf("unexportedMethod() = %v, want %v", got, tt.want)
586 + }
587 + })
588 + }
589 +}
590 -- @alias_constructor_on_underlying_type/aliasreceiver/aliasreceiver_test.go --
591 @@ -3 +3,23 @@
592 +import "testing"
593 +
594 +
595 +func Test_baz_method(t *testing.T) {
596 + tests := []struct {
597 + name string // description of this test case
598 + // Named input parameters for target function.
599 + in string
600 + want string
601 + }{
602 + // TODO: Add test cases.
603 + }
604 + for _, tt := range tests {
605 + t.Run(tt.name, func(t *testing.T) {
606 + b := newBaz0()
607 + got := b.method(tt.in)
608 + // TODO: update the condition below to compare got with tt.want.
609 + if true {
610 + t.Errorf("method() = %v, want %v", got, tt.want)
611 + }
612 + })
613 + }
614 +}
615 -- @alias_constructor_on_different_alias_type/aliasreceiver/aliasreceiver_test.go --
616 @@ -3 +3,26 @@
617 +import "testing"
618 +
619 +
620 +func TestQux_method(t *testing.T) {
621 + tests := []struct {
622 + name string // description of this test case
623 + // Named input parameters for target function.
624 + in string
625 + want string
626 + }{
627 + // TODO: Add test cases.
628 + }
629 + for _, tt := range tests {
630 + t.Run(tt.name, func(t *testing.T) {
631 + q, err := newQux1()
632 + if err != nil {
633 + t.Fatalf("could not construct receiver type: %v", err)
634 + }
635 + got := q.method(tt.in)
636 + // TODO: update the condition below to compare got with tt.want.
637 + if true {
638 + t.Errorf("method() = %v, want %v", got, tt.want)
639 + }
640 + })
641 + }
642 +}
643 -- multiinputoutput/multiinputoutput.go --
644 package main
645
646 func Foo(in, in2, in3, in4 string) (out, out1, out2 string) {return "", "", ""} //@codeaction("Foo", "source.addTest", edit=multi_input_output)
647
648 -- @multi_input_output/multiinputoutput/multiinputoutput_test.go --
649 @@ -0,0 +1,37 @@
650 +package main_test
651 +
652 +import(
653 + "golang.org/lsptests/addtest/multiinputoutput"
654 + "testing"
655 +)
656 +
657 +func TestFoo(t *testing.T) {
658 + tests := []struct {
659 + name string // description of this test case
660 + // Named input parameters for target function.
661 + in string
662 + in2 string
663 + in3 string
664 + in4 string
665 + want string
666 + want2 string
667 + want3 string
668 + }{
669 + // TODO: Add test cases.
670 + }
671 + for _, tt := range tests {
672 + t.Run(tt.name, func(t *testing.T) {
673 + got, got2, got3 := main.Foo(tt.in, tt.in2, tt.in3, tt.in4)
674 + // TODO: update the condition below to compare got with tt.want.
675 + if true {
676 + t.Errorf("Foo() = %v, want %v", got, tt.want)
677 + }
678 + if true {
679 + t.Errorf("Foo() = %v, want %v", got2, tt.want2)
680 + }
681 + if true {
682 + t.Errorf("Foo() = %v, want %v", got3, tt.want3)
683 + }
684 + })
685 + }
686 +}
687 -- xpackagerename/xpackagerename.go --
688 package main
689
690 import (
691 mytime "time"
692 myast "go/ast"
693 mytest "testing"
694 )
695
696 var local mytest.T
697
698 func Foo(t mytime.Time, a *myast.Node) (mytime.Time, *myast.Node) {return t, a} //@codeaction("Foo", "source.addTest", edit=xpackage_rename)
699
700 -- @xpackage_rename/xpackagerename/xpackagerename_test.go --
701 @@ -0,0 +1,33 @@
702 +package main_test
703 +
704 +import(
705 + myast "go/ast"
706 + "golang.org/lsptests/addtest/xpackagerename"
707 + mytest "testing"
708 + mytime "time"
709 +)
710 +
711 +func TestFoo(t *mytest.T) {
712 + tests := []struct {
713 + name string // description of this test case
714 + // Named input parameters for target function.
715 + t mytime.Time
716 + a *myast.Node
717 + want mytime.Time
718 + want2 *myast.Node
719 + }{
720 + // TODO: Add test cases.
721 + }
722 + for _, tt := range tests {
723 + t.Run(tt.name, func(t *mytest.T) {
724 + got, got2 := main.Foo(tt.t, tt.a)
725 + // TODO: update the condition below to compare got with tt.want.
726 + if true {
727 + t.Errorf("Foo() = %v, want %v", got, tt.want)
728 + }
729 + if true {
730 + t.Errorf("Foo() = %v, want %v", got2, tt.want2)
731 + }
732 + })
733 + }
734 +}
735 -- xtestpackagerename/xtestpackagerename.go --
736 package main
737
738 import (
739 mytime "time"
740 myast "go/ast"
741 mytest "testing"
742 )
743
744 var local mytest.T
745
746 func Foo(t mytime.Time, a *myast.Node) (mytime.Time, *myast.Node) {return t, a} //@codeaction("Foo", "source.addTest", edit=xtest_package_rename)
747
748 -- xtestpackagerename/xtestpackagerename_test.go --
749 package main_test
750
751 import (
752 yourast "go/ast"
753 yourtest "testing"
754 yourtime "time"
755 )
756
757 var fooTime = yourtime.Time{}
758 var fooNode = yourast.Node{}
759 var fooT yourtest.T
760
761 -- @xtest_package_rename/xtestpackagerename/xtestpackagerename_test.go --
762 @@ -7 +7,2 @@
763 +
764 + "golang.org/lsptests/addtest/xtestpackagerename"
765 @@ -13 +15,25 @@
766 +
767 +func TestFoo(t *yourtest.T) {
768 + tests := []struct {
769 + name string // description of this test case
770 + // Named input parameters for target function.
771 + t yourtime.Time
772 + a *yourast.Node
773 + want yourtime.Time
774 + want2 *yourast.Node
775 + }{
776 + // TODO: Add test cases.
777 + }
778 + for _, tt := range tests {
779 + t.Run(tt.name, func(t *yourtest.T) {
780 + got, got2 := main.Foo(tt.t, tt.a)
781 + // TODO: update the condition below to compare got with tt.want.
782 + if true {
783 + t.Errorf("Foo() = %v, want %v", got, tt.want)
784 + }
785 + if true {
786 + t.Errorf("Foo() = %v, want %v", got2, tt.want2)
787 + }
788 + })
789 + }
790 +}
791 -- returnwitherror/returnwitherror.go --
792 package main
793
794 func OnlyErr() error {return nil} //@codeaction("OnlyErr", "source.addTest", edit=return_only_error)
795 func StringErr() (string, error) {return "", nil} //@codeaction("StringErr", "source.addTest", edit=return_string_error)
796 func MultipleStringErr() (string, string, string, error) {return "", "", "", nil} //@codeaction("MultipleStringErr", "source.addTest", edit=return_multiple_string_error)
797
798 -- @return_only_error/returnwitherror/returnwitherror_test.go --
799 @@ -0,0 +1,29 @@
800 +package main_test
801 +
802 +import(
803 + "golang.org/lsptests/addtest/returnwitherror"
804 + "testing"
805 +)
806 +
807 +func TestOnlyErr(t *testing.T) {
808 + tests := []struct {
809 + name string // description of this test case
810 + wantErr bool
811 + }{
812 + // TODO: Add test cases.
813 + }
814 + for _, tt := range tests {
815 + t.Run(tt.name, func(t *testing.T) {
816 + gotErr := main.OnlyErr()
817 + if gotErr != nil {
818 + if !tt.wantErr {
819 + t.Errorf("OnlyErr() failed: %v", gotErr)
820 + }
821 + return
822 + }
823 + if tt.wantErr {
824 + t.Fatal("OnlyErr() succeeded unexpectedly")
825 + }
826 + })
827 + }
828 +}
829 -- @return_string_error/returnwitherror/returnwitherror_test.go --
830 @@ -0,0 +1,34 @@
831 +package main_test
832 +
833 +import(
834 + "golang.org/lsptests/addtest/returnwitherror"
835 + "testing"
836 +)
837 +
838 +func TestStringErr(t *testing.T) {
839 + tests := []struct {
840 + name string // description of this test case
841 + want string
842 + wantErr bool
843 + }{
844 + // TODO: Add test cases.
845 + }
846 + for _, tt := range tests {
847 + t.Run(tt.name, func(t *testing.T) {
848 + got, gotErr := main.StringErr()
849 + if gotErr != nil {
850 + if !tt.wantErr {
851 + t.Errorf("StringErr() failed: %v", gotErr)
852 + }
853 + return
854 + }
855 + if tt.wantErr {
856 + t.Fatal("StringErr() succeeded unexpectedly")
857 + }
858 + // TODO: update the condition below to compare got with tt.want.
859 + if true {
860 + t.Errorf("StringErr() = %v, want %v", got, tt.want)
861 + }
862 + })
863 + }
864 +}
865 -- @return_multiple_string_error/returnwitherror/returnwitherror_test.go --
866 @@ -0,0 +1,42 @@
867 +package main_test
868 +
869 +import(
870 + "golang.org/lsptests/addtest/returnwitherror"
871 + "testing"
872 +)
873 +
874 +func TestMultipleStringErr(t *testing.T) {
875 + tests := []struct {
876 + name string // description of this test case
877 + want string
878 + want2 string
879 + want3 string
880 + wantErr bool
881 + }{
882 + // TODO: Add test cases.
883 + }
884 + for _, tt := range tests {
885 + t.Run(tt.name, func(t *testing.T) {
886 + got, got2, got3, gotErr := main.MultipleStringErr()
887 + if gotErr != nil {
888 + if !tt.wantErr {
889 + t.Errorf("MultipleStringErr() failed: %v", gotErr)
890 + }
891 + return
892 + }
893 + if tt.wantErr {
894 + t.Fatal("MultipleStringErr() succeeded unexpectedly")
895 + }
896 + // TODO: update the condition below to compare got with tt.want.
897 + if true {
898 + t.Errorf("MultipleStringErr() = %v, want %v", got, tt.want)
899 + }
900 + if true {
901 + t.Errorf("MultipleStringErr() = %v, want %v", got2, tt.want2)
902 + }
903 + if true {
904 + t.Errorf("MultipleStringErr() = %v, want %v", got3, tt.want3)
905 + }
906 + })
907 + }
908 +}
909 -- constructor/constructor.go --
910 package main
911
912 // Constructor returns the type T.
913 func NewReturnType() ReturnType {return ReturnType{}}
914
915 type ReturnType struct {}
916
917 func (*ReturnType) Method(in string) string {return in} //@codeaction("Method", "source.addTest", edit=constructor_return_type)
918
919 // Constructor returns the type T and an error.
920 func NewReturnTypeError() (ReturnTypeError, error) {return ReturnTypeError{}, nil}
921
922 type ReturnTypeError struct {}
923
924 func (*ReturnTypeError) Method(in string) string {return in} //@codeaction("Method", "source.addTest", edit=constructor_return_type_error)
925
926 // Constructor returns the type *T.
927 func NewReturnPtr() *ReturnPtr {return nil}
928
929 type ReturnPtr struct {}
930
931 func (*ReturnPtr) Method(in string) string {return in} //@codeaction("Method", "source.addTest", edit=constructor_return_ptr)
932
933 // Constructor returns the type *T and an error.
934 func NewReturnPtrError() (*ReturnPtrError, error) {return nil, nil}
935
936 type ReturnPtrError struct {}
937
938 func (*ReturnPtrError) Method(in string) string {return in} //@codeaction("Method", "source.addTest", edit=constructor_return_ptr_error)
939
940 -- @constructor_return_type/constructor/constructor_test.go --
941 @@ -0,0 +1,27 @@
942 +package main_test
943 +
944 +import(
945 + "golang.org/lsptests/addtest/constructor"
946 + "testing"
947 +)
948 +
949 +func TestReturnType_Method(t *testing.T) {
950 + tests := []struct {
951 + name string // description of this test case
952 + // Named input parameters for target function.
953 + in string
954 + want string
955 + }{
956 + // TODO: Add test cases.
957 + }
958 + for _, tt := range tests {
959 + t.Run(tt.name, func(t *testing.T) {
960 + r := main.NewReturnType()
961 + got := r.Method(tt.in)
962 + // TODO: update the condition below to compare got with tt.want.
963 + if true {
964 + t.Errorf("Method() = %v, want %v", got, tt.want)
965 + }
966 + })
967 + }
968 +}
969 -- @constructor_return_type_error/constructor/constructor_test.go --
970 @@ -0,0 +1,30 @@
971 +package main_test
972 +
973 +import(
974 + "golang.org/lsptests/addtest/constructor"
975 + "testing"
976 +)
977 +
978 +func TestReturnTypeError_Method(t *testing.T) {
979 + tests := []struct {
980 + name string // description of this test case
981 + // Named input parameters for target function.
982 + in string
983 + want string
984 + }{
985 + // TODO: Add test cases.
986 + }
987 + for _, tt := range tests {
988 + t.Run(tt.name, func(t *testing.T) {
989 + r, err := main.NewReturnTypeError()
990 + if err != nil {
991 + t.Fatalf("could not construct receiver type: %v", err)
992 + }
993 + got := r.Method(tt.in)
994 + // TODO: update the condition below to compare got with tt.want.
995 + if true {
996 + t.Errorf("Method() = %v, want %v", got, tt.want)
997 + }
998 + })
999 + }
1000 +}
1001 -- @constructor_return_ptr/constructor/constructor_test.go --
1002 @@ -0,0 +1,27 @@
1003 +package main_test
1004 +
1005 +import(
1006 + "golang.org/lsptests/addtest/constructor"
1007 + "testing"
1008 +)
1009 +
1010 +func TestReturnPtr_Method(t *testing.T) {
1011 + tests := []struct {
1012 + name string // description of this test case
1013 + // Named input parameters for target function.
1014 + in string
1015 + want string
1016 + }{
1017 + // TODO: Add test cases.
1018 + }
1019 + for _, tt := range tests {
1020 + t.Run(tt.name, func(t *testing.T) {
1021 + r := main.NewReturnPtr()
1022 + got := r.Method(tt.in)
1023 + // TODO: update the condition below to compare got with tt.want.
1024 + if true {
1025 + t.Errorf("Method() = %v, want %v", got, tt.want)
1026 + }
1027 + })
1028 + }
1029 +}
1030 -- @constructor_return_ptr_error/constructor/constructor_test.go --
1031 @@ -0,0 +1,30 @@
1032 +package main_test
1033 +
1034 +import(
1035 + "golang.org/lsptests/addtest/constructor"
1036 + "testing"
1037 +)
1038 +
1039 +func TestReturnPtrError_Method(t *testing.T) {
1040 + tests := []struct {
1041 + name string // description of this test case
1042 + // Named input parameters for target function.
1043 + in string
1044 + want string
1045 + }{
1046 + // TODO: Add test cases.
1047 + }
1048 + for _, tt := range tests {
1049 + t.Run(tt.name, func(t *testing.T) {
1050 + r, err := main.NewReturnPtrError()
1051 + if err != nil {
1052 + t.Fatalf("could not construct receiver type: %v", err)
1053 + }
1054 + got := r.Method(tt.in)
1055 + // TODO: update the condition below to compare got with tt.want.
1056 + if true {
1057 + t.Errorf("Method() = %v, want %v", got, tt.want)
1058 + }
1059 + })
1060 + }
1061 +}
1062 -- constructorcomparison/constructorcomparison.go --
1063 package main
1064
1065 // Foo have two constructors. NewFoo is preferred over others.
1066 func CreateAFoo() Foo {return Foo{}}
1067 func NewFoo() Foo {return Foo{}}
1068
1069 type Foo struct{}
1070
1071 func (*Foo) Method(in string) string {return in} //@codeaction("Method", "source.addTest", edit=constructor_comparison_new)
1072
1073 // Bar have two constructors. Bar is preferred due to alphabetical ordering.
1074 func ABar() (Bar, error) {return Bar{}, nil}
1075 // func CreateABar() Bar {return Bar{}}
1076
1077 type Bar struct{}
1078
1079 func (*Bar) Method(in string) string {return in} //@codeaction("Method", "source.addTest", edit=constructor_comparison_alphabetical)
1080
1081 -- @constructor_comparison_new/constructorcomparison/constructorcomparison_test.go --
1082 @@ -0,0 +1,27 @@
1083 +package main_test
1084 +
1085 +import(
1086 + "golang.org/lsptests/addtest/constructorcomparison"
1087 + "testing"
1088 +)
1089 +
1090 +func TestFoo_Method(t *testing.T) {
1091 + tests := []struct {
1092 + name string // description of this test case
1093 + // Named input parameters for target function.
1094 + in string
1095 + want string
1096 + }{
1097 + // TODO: Add test cases.
1098 + }
1099 + for _, tt := range tests {
1100 + t.Run(tt.name, func(t *testing.T) {
1101 + f := main.NewFoo()
1102 + got := f.Method(tt.in)
1103 + // TODO: update the condition below to compare got with tt.want.
1104 + if true {
1105 + t.Errorf("Method() = %v, want %v", got, tt.want)
1106 + }
1107 + })
1108 + }
1109 +}
1110 -- @constructor_comparison_alphabetical/constructorcomparison/constructorcomparison_test.go --
1111 @@ -0,0 +1,30 @@
1112 +package main_test
1113 +
1114 +import(
1115 + "golang.org/lsptests/addtest/constructorcomparison"
1116 + "testing"
1117 +)
1118 +
1119 +func TestBar_Method(t *testing.T) {
1120 + tests := []struct {
1121 + name string // description of this test case
1122 + // Named input parameters for target function.
1123 + in string
1124 + want string
1125 + }{
1126 + // TODO: Add test cases.
1127 + }
1128 + for _, tt := range tests {
1129 + t.Run(tt.name, func(t *testing.T) {
1130 + b, err := main.ABar()
1131 + if err != nil {
1132 + t.Fatalf("could not construct receiver type: %v", err)
1133 + }
1134 + got := b.Method(tt.in)
1135 + // TODO: update the condition below to compare got with tt.want.
1136 + if true {
1137 + t.Errorf("Method() = %v, want %v", got, tt.want)
1138 + }
1139 + })
1140 + }
1141 +}
1142 -- unnamedparam/unnamedparam.go --
1143 package main
1144
1145 import "time"
1146
1147 func FooInputBasic(one, two, _ string, _ int) (out, out1, out2 string) {return "", "", ""} //@codeaction("Foo", "source.addTest", edit=function_basic_type)
1148
1149 func FooInputStruct(one string, _ time.Time) (out, out1, out2 string) {return "", "", ""} //@codeaction("Foo", "source.addTest", edit=function_struct_type)
1150
1151 func FooInputPtr(one string, _ *time.Time) (out, out1, out2 string) {return "", "", ""} //@codeaction("Foo", "source.addTest", edit=function_ptr_type)
1152
1153 func FooInputFunc(one string, _ func(time.Time) *time.Time) (out, out1, out2 string) {return "", "", ""} //@codeaction("Foo", "source.addTest", edit=function_func_type)
1154
1155 type BarInputBasic struct{}
1156
1157 func NewBarInputBasic(one, two, _ string, _ int) *BarInputBasic {return nil}
1158
1159 func (r *BarInputBasic) Method(one, two, _ string, _ int) {} //@codeaction("Method", "source.addTest", edit=constructor_basic_type)
1160
1161 type BarInputStruct struct{}
1162
1163 func NewBarInputStruct(one string, _ time.Time) *BarInputStruct {return nil}
1164
1165 func (r *BarInputStruct) Method(one string, _ time.Time) {} //@codeaction("Method", "source.addTest", edit=constructor_struct_type)
1166
1167 type BarInputPtr struct{}
1168
1169 func NewBarInputPtr(one string, _ *time.Time) *BarInputPtr {return nil}
1170
1171 func (r *BarInputPtr) Method(one string, _ *time.Time) {} //@codeaction("Method", "source.addTest", edit=constructor_ptr_type)
1172
1173 type BarInputFunction struct{}
1174
1175 func NewBarInputFunction(one string, _ func(time.Time) *time.Time) *BarInputFunction {return nil}
1176
1177 func (r *BarInputFunction) Method(one string, _ func(time.Time) *time.Time) {} //@codeaction("Method", "source.addTest", edit=constructor_func_type)
1178
1179 -- @function_basic_type/unnamedparam/unnamedparam_test.go --
1180 @@ -0,0 +1,35 @@
1181 +package main_test
1182 +
1183 +import(
1184 + "golang.org/lsptests/addtest/unnamedparam"
1185 + "testing"
1186 +)
1187 +
1188 +func TestFooInputBasic(t *testing.T) {
1189 + tests := []struct {
1190 + name string // description of this test case
1191 + // Named input parameters for target function.
1192 + one string
1193 + two string
1194 + want string
1195 + want2 string
1196 + want3 string
1197 + }{
1198 + // TODO: Add test cases.
1199 + }
1200 + for _, tt := range tests {
1201 + t.Run(tt.name, func(t *testing.T) {
1202 + got, got2, got3 := main.FooInputBasic(tt.one, tt.two, "", 0)
1203 + // TODO: update the condition below to compare got with tt.want.
1204 + if true {
1205 + t.Errorf("FooInputBasic() = %v, want %v", got, tt.want)
1206 + }
1207 + if true {
1208 + t.Errorf("FooInputBasic() = %v, want %v", got2, tt.want2)
1209 + }
1210 + if true {
1211 + t.Errorf("FooInputBasic() = %v, want %v", got3, tt.want3)
1212 + }
1213 + })
1214 + }
1215 +}
1216 -- @function_func_type/unnamedparam/unnamedparam_test.go --
1217 @@ -0,0 +1,35 @@
1218 +package main_test
1219 +
1220 +import(
1221 + "golang.org/lsptests/addtest/unnamedparam"
1222 + "testing"
1223 + "time"
1224 +)
1225 +
1226 +func TestFooInputFunc(t *testing.T) {
1227 + tests := []struct {
1228 + name string // description of this test case
1229 + // Named input parameters for target function.
1230 + one string
1231 + want string
1232 + want2 string
1233 + want3 string
1234 + }{
1235 + // TODO: Add test cases.
1236 + }
1237 + for _, tt := range tests {
1238 + t.Run(tt.name, func(t *testing.T) {
1239 + got, got2, got3 := main.FooInputFunc(tt.one, nil)
1240 + // TODO: update the condition below to compare got with tt.want.
1241 + if true {
1242 + t.Errorf("FooInputFunc() = %v, want %v", got, tt.want)
1243 + }
1244 + if true {
1245 + t.Errorf("FooInputFunc() = %v, want %v", got2, tt.want2)
1246 + }
1247 + if true {
1248 + t.Errorf("FooInputFunc() = %v, want %v", got3, tt.want3)
1249 + }
1250 + })
1251 + }
1252 +}
1253 -- @function_ptr_type/unnamedparam/unnamedparam_test.go --
1254 @@ -0,0 +1,35 @@
1255 +package main_test
1256 +
1257 +import(
1258 + "golang.org/lsptests/addtest/unnamedparam"
1259 + "testing"
1260 + "time"
1261 +)
1262 +
1263 +func TestFooInputPtr(t *testing.T) {
1264 + tests := []struct {
1265 + name string // description of this test case
1266 + // Named input parameters for target function.
1267 + one string
1268 + want string
1269 + want2 string
1270 + want3 string
1271 + }{
1272 + // TODO: Add test cases.
1273 + }
1274 + for _, tt := range tests {
1275 + t.Run(tt.name, func(t *testing.T) {
1276 + got, got2, got3 := main.FooInputPtr(tt.one, nil)
1277 + // TODO: update the condition below to compare got with tt.want.
1278 + if true {
1279 + t.Errorf("FooInputPtr() = %v, want %v", got, tt.want)
1280 + }
1281 + if true {
1282 + t.Errorf("FooInputPtr() = %v, want %v", got2, tt.want2)
1283 + }
1284 + if true {
1285 + t.Errorf("FooInputPtr() = %v, want %v", got3, tt.want3)
1286 + }
1287 + })
1288 + }
1289 +}
1290 -- @function_struct_type/unnamedparam/unnamedparam_test.go --
1291 @@ -0,0 +1,35 @@
1292 +package main_test
1293 +
1294 +import(
1295 + "golang.org/lsptests/addtest/unnamedparam"
1296 + "testing"
1297 + "time"
1298 +)
1299 +
1300 +func TestFooInputStruct(t *testing.T) {
1301 + tests := []struct {
1302 + name string // description of this test case
1303 + // Named input parameters for target function.
1304 + one string
1305 + want string
1306 + want2 string
1307 + want3 string
1308 + }{
1309 + // TODO: Add test cases.
1310 + }
1311 + for _, tt := range tests {
1312 + t.Run(tt.name, func(t *testing.T) {
1313 + got, got2, got3 := main.FooInputStruct(tt.one, time.Time{})
1314 + // TODO: update the condition below to compare got with tt.want.
1315 + if true {
1316 + t.Errorf("FooInputStruct() = %v, want %v", got, tt.want)
1317 + }
1318 + if true {
1319 + t.Errorf("FooInputStruct() = %v, want %v", got2, tt.want2)
1320 + }
1321 + if true {
1322 + t.Errorf("FooInputStruct() = %v, want %v", got3, tt.want3)
1323 + }
1324 + })
1325 + }
1326 +}
1327 -- @constructor_basic_type/unnamedparam/unnamedparam_test.go --
1328 @@ -0,0 +1,26 @@
1329 +package main_test
1330 +
1331 +import(
1332 + "golang.org/lsptests/addtest/unnamedparam"
1333 + "testing"
1334 +)
1335 +
1336 +func TestBarInputBasic_Method(t *testing.T) {
1337 + tests := []struct {
1338 + name string // description of this test case
1339 + // Named input parameters for receiver constructor.
1340 + cone string
1341 + ctwo string
1342 + // Named input parameters for target function.
1343 + one string
1344 + two string
1345 + }{
1346 + // TODO: Add test cases.
1347 + }
1348 + for _, tt := range tests {
1349 + t.Run(tt.name, func(t *testing.T) {
1350 + r := main.NewBarInputBasic(tt.cone, tt.ctwo, "", 0)
1351 + r.Method(tt.one, tt.two, "", 0)
1352 + })
1353 + }
1354 +}
1355 -- @constructor_func_type/unnamedparam/unnamedparam_test.go --
1356 @@ -0,0 +1,25 @@
1357 +package main_test
1358 +
1359 +import(
1360 + "golang.org/lsptests/addtest/unnamedparam"
1361 + "testing"
1362 + "time"
1363 +)
1364 +
1365 +func TestBarInputFunction_Method(t *testing.T) {
1366 + tests := []struct {
1367 + name string // description of this test case
1368 + // Named input parameters for receiver constructor.
1369 + cone string
1370 + // Named input parameters for target function.
1371 + one string
1372 + }{
1373 + // TODO: Add test cases.
1374 + }
1375 + for _, tt := range tests {
1376 + t.Run(tt.name, func(t *testing.T) {
1377 + r := main.NewBarInputFunction(tt.cone, nil)
1378 + r.Method(tt.one, nil)
1379 + })
1380 + }
1381 +}
1382 -- @constructor_ptr_type/unnamedparam/unnamedparam_test.go --
1383 @@ -0,0 +1,25 @@
1384 +package main_test
1385 +
1386 +import(
1387 + "golang.org/lsptests/addtest/unnamedparam"
1388 + "testing"
1389 + "time"
1390 +)
1391 +
1392 +func TestBarInputPtr_Method(t *testing.T) {
1393 + tests := []struct {
1394 + name string // description of this test case
1395 + // Named input parameters for receiver constructor.
1396 + cone string
1397 + // Named input parameters for target function.
1398 + one string
1399 + }{
1400 + // TODO: Add test cases.
1401 + }
1402 + for _, tt := range tests {
1403 + t.Run(tt.name, func(t *testing.T) {
1404 + r := main.NewBarInputPtr(tt.cone, nil)
1405 + r.Method(tt.one, nil)
1406 + })
1407 + }
1408 +}
1409 -- @constructor_struct_type/unnamedparam/unnamedparam_test.go --
1410 @@ -0,0 +1,25 @@
1411 +package main_test
1412 +
1413 +import(
1414 + "golang.org/lsptests/addtest/unnamedparam"
1415 + "testing"
1416 + "time"
1417 +)
1418 +
1419 +func TestBarInputStruct_Method(t *testing.T) {
1420 + tests := []struct {
1421 + name string // description of this test case
1422 + // Named input parameters for receiver constructor.
1423 + cone string
1424 + // Named input parameters for target function.
1425 + one string
1426 + }{
1427 + // TODO: Add test cases.
1428 + }
1429 + for _, tt := range tests {
1430 + t.Run(tt.name, func(t *testing.T) {
1431 + r := main.NewBarInputStruct(tt.cone, time.Time{})
1432 + r.Method(tt.one, time.Time{})
1433 + })
1434 + }
1435 +}
1436 -- contextinput/contextinput.go --
1437 package main
1438
1439 import "context"
1440
1441 func Function(ctx context.Context, _, _ string) (out, out1, out2 string) {return "", "", ""} //@codeaction("Function", "source.addTest", edit=function_context)
1442
1443 type Foo struct {}
1444
1445 func NewFoo(ctx context.Context) (*Foo, error) {return nil, nil}
1446
1447 func (*Foo) Method(ctx context.Context, _, _ string) (out, out1, out2 string) {return "", "", ""} //@codeaction("Method", "source.addTest", edit=method_context)
1448 -- contextinput/contextinput_test.go --
1449 package main_test
1450
1451 -- @function_context/contextinput/contextinput_test.go --
1452 @@ -3 +3,32 @@
1453 +import (
1454 + "testing"
1455 +
1456 + "golang.org/lsptests/addtest/contextinput"
1457 +)
1458 +
1459 +
1460 +func TestFunction(t *testing.T) {
1461 + tests := []struct {
1462 + name string // description of this test case
1463 + want string
1464 + want2 string
1465 + want3 string
1466 + }{
1467 + // TODO: Add test cases.
1468 + }
1469 + for _, tt := range tests {
1470 + t.Run(tt.name, func(t *testing.T) {
1471 + got, got2, got3 := main.Function(t.Context(), "", "")
1472 + // TODO: update the condition below to compare got with tt.want.
1473 + if true {
1474 + t.Errorf("Function() = %v, want %v", got, tt.want)
1475 + }
1476 + if true {
1477 + t.Errorf("Function() = %v, want %v", got2, tt.want2)
1478 + }
1479 + if true {
1480 + t.Errorf("Function() = %v, want %v", got3, tt.want3)
1481 + }
1482 + })
1483 + }
1484 +}
1485 -- @method_context/contextinput/contextinput_test.go --
1486 @@ -3 +3,36 @@
1487 +import (
1488 + "testing"
1489 +
1490 + "golang.org/lsptests/addtest/contextinput"
1491 +)
1492 +
1493 +
1494 +func TestFoo_Method(t *testing.T) {
1495 + tests := []struct {
1496 + name string // description of this test case
1497 + want string
1498 + want2 string
1499 + want3 string
1500 + }{
1501 + // TODO: Add test cases.
1502 + }
1503 + for _, tt := range tests {
1504 + t.Run(tt.name, func(t *testing.T) {
1505 + f, err := main.NewFoo(t.Context())
1506 + if err != nil {
1507 + t.Fatalf("could not construct receiver type: %v", err)
1508 + }
1509 + got, got2, got3 := f.Method(t.Context(), "", "")
1510 + // TODO: update the condition below to compare got with tt.want.
1511 + if true {
1512 + t.Errorf("Method() = %v, want %v", got, tt.want)
1513 + }
1514 + if true {
1515 + t.Errorf("Method() = %v, want %v", got2, tt.want2)
1516 + }
1517 + if true {
1518 + t.Errorf("Method() = %v, want %v", got3, tt.want3)
1519 + }
1520 + })
1521 + }
1522 +}
1523 -- typeparameter/typeparameter.go --
1524 package main
1525
1526 func Function[T any] () {} // no suggested fix
1527
1528 type Foo struct {}
1529
1530 func NewFoo()
1531
1532 func (*Foo) Method[T any]() {} // no suggested fix
1533 -- varargsinput/varargsinput.go --
1534 package main
1535
1536 func Function(args ...string) (out, out1, out2 string) {return args[0], "", ""} //@codeaction("Function", "source.addTest", edit=function_varargsinput)
1537
1538 type Foo struct {}
1539
1540 func NewFoo(args ...string) (*Foo, error) {
1541 _ = args
1542 return nil, nil
1543 }
1544
1545 func (*Foo) Method(args ...string) (out, out1, out2 string) {return args[0], "", ""} //@codeaction("Method", "source.addTest", edit=method_varargsinput)
1546 -- varargsinput/varargsinput_test.go --
1547 package main_test
1548 -- @function_varargsinput/varargsinput/varargsinput_test.go --
1549 @@ -2 +2,34 @@
1550 +
1551 +import (
1552 + "testing"
1553 +
1554 + "golang.org/lsptests/addtest/varargsinput"
1555 +)
1556 +
1557 +func TestFunction(t *testing.T) {
1558 + tests := []struct {
1559 + name string // description of this test case
1560 + // Named input parameters for target function.
1561 + args []string
1562 + want string
1563 + want2 string
1564 + want3 string
1565 + }{
1566 + // TODO: Add test cases.
1567 + }
1568 + for _, tt := range tests {
1569 + t.Run(tt.name, func(t *testing.T) {
1570 + got, got2, got3 := main.Function(tt.args...)
1571 + // TODO: update the condition below to compare got with tt.want.
1572 + if true {
1573 + t.Errorf("Function() = %v, want %v", got, tt.want)
1574 + }
1575 + if true {
1576 + t.Errorf("Function() = %v, want %v", got2, tt.want2)
1577 + }
1578 + if true {
1579 + t.Errorf("Function() = %v, want %v", got3, tt.want3)
1580 + }
1581 + })
1582 + }
1583 +}
1584 -- @method_varargsinput/varargsinput/varargsinput_test.go --
1585 @@ -2 +2,40 @@
1586 +
1587 +import (
1588 + "testing"
1589 +
1590 + "golang.org/lsptests/addtest/varargsinput"
1591 +)
1592 +
1593 +func TestFoo_Method(t *testing.T) {
1594 + tests := []struct {
1595 + name string // description of this test case
1596 + // Named input parameters for receiver constructor.
1597 + cargs []string
1598 + // Named input parameters for target function.
1599 + args []string
1600 + want string
1601 + want2 string
1602 + want3 string
1603 + }{
1604 + // TODO: Add test cases.
1605 + }
1606 + for _, tt := range tests {
1607 + t.Run(tt.name, func(t *testing.T) {
1608 + f, err := main.NewFoo(tt.cargs...)
1609 + if err != nil {
1610 + t.Fatalf("could not construct receiver type: %v", err)
1611 + }
1612 + got, got2, got3 := f.Method(tt.args...)
1613 + // TODO: update the condition below to compare got with tt.want.
1614 + if true {
1615 + t.Errorf("Method() = %v, want %v", got, tt.want)
1616 + }
1617 + if true {
1618 + t.Errorf("Method() = %v, want %v", got2, tt.want2)
1619 + }
1620 + if true {
1621 + t.Errorf("Method() = %v, want %v", got3, tt.want3)
1622 + }
1623 + })
1624 + }
1625 +}
1626 -- unusedvarargsinput/unusedvarargsinput.go --
1627 package main
1628
1629 func Function(_ ...string) (out, out1, out2 string) {return "", "", ""} //@codeaction("Function", "source.addTest", edit=function_unusedvarargsinput)
1630
1631 type Foo struct {}
1632
1633 func NewFoo(_ ...string) (*Foo, error) {
1634 return nil, nil
1635 }
1636
1637 func (*Foo) Method(_ ...string) (out, out1, out2 string) {return "", "", ""} //@codeaction("Method", "source.addTest", edit=method_unusedvarargsinput)
1638 -- unusedvarargsinput/unusedvarargsinput_test.go --
1639 package main_test
1640 -- @function_unusedvarargsinput/unusedvarargsinput/unusedvarargsinput_test.go --
1641 @@ -2 +2,32 @@
1642 +
1643 +import (
1644 + "testing"
1645 +
1646 + "golang.org/lsptests/addtest/unusedvarargsinput"
1647 +)
1648 +
1649 +func TestFunction(t *testing.T) {
1650 + tests := []struct {
1651 + name string // description of this test case
1652 + want string
1653 + want2 string
1654 + want3 string
1655 + }{
1656 + // TODO: Add test cases.
1657 + }
1658 + for _, tt := range tests {
1659 + t.Run(tt.name, func(t *testing.T) {
1660 + got, got2, got3 := main.Function()
1661 + // TODO: update the condition below to compare got with tt.want.
1662 + if true {
1663 + t.Errorf("Function() = %v, want %v", got, tt.want)
1664 + }
1665 + if true {
1666 + t.Errorf("Function() = %v, want %v", got2, tt.want2)
1667 + }
1668 + if true {
1669 + t.Errorf("Function() = %v, want %v", got3, tt.want3)
1670 + }
1671 + })
1672 + }
1673 +}
1674 -- @method_unusedvarargsinput/unusedvarargsinput/unusedvarargsinput_test.go --
1675 @@ -2 +2,36 @@
1676 +
1677 +import (
1678 + "testing"
1679 +
1680 + "golang.org/lsptests/addtest/unusedvarargsinput"
1681 +)
1682 +
1683 +func TestFoo_Method(t *testing.T) {
1684 + tests := []struct {
1685 + name string // description of this test case
1686 + want string
1687 + want2 string
1688 + want3 string
1689 + }{
1690 + // TODO: Add test cases.
1691 + }
1692 + for _, tt := range tests {
1693 + t.Run(tt.name, func(t *testing.T) {
1694 + f, err := main.NewFoo()
1695 + if err != nil {
1696 + t.Fatalf("could not construct receiver type: %v", err)
1697 + }
1698 + got, got2, got3 := f.Method()
1699 + // TODO: update the condition below to compare got with tt.want.
1700 + if true {
1701 + t.Errorf("Method() = %v, want %v", got, tt.want)
1702 + }
1703 + if true {
1704 + t.Errorf("Method() = %v, want %v", got2, tt.want2)
1705 + }
1706 + if true {
1707 + t.Errorf("Method() = %v, want %v", got3, tt.want3)
1708 + }
1709 + })
1710 + }
1711 +}