Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / tools@v0.0.0-20201105173854-bc9fc8d8c4bc / internal / lsp / testdata / signature / signature.go
1 // Package signature has tests for signature help.
2 package signature
3
4 import (
5         "bytes"
6         "encoding/json"
7         "math/big"
8 )
9
10 func Foo(a string, b int) (c bool) {
11         return
12 }
13
14 func Bar(float64, ...byte) {
15 }
16
17 type myStruct struct{}
18
19 func (*myStruct) foo(e *json.Decoder) (*big.Int, error) {
20         return nil, nil
21 }
22
23 type MyType struct{}
24
25 type MyFunc func(foo int) string
26
27 type Alias = int
28 type OtherAlias = int
29 type StringAlias = string
30
31 func AliasSlice(a []*Alias) (b Alias)                                 { return 0 }
32 func AliasMap(a map[*Alias]StringAlias) (b, c map[*Alias]StringAlias) { return nil, nil }
33 func OtherAliasMap(a, b map[Alias]OtherAlias) map[Alias]OtherAlias    { return nil }
34
35 func Qux() {
36         Foo("foo", 123) //@signature("(", "Foo(a string, b int) (c bool)", 0)
37         Foo("foo", 123) //@signature("123", "Foo(a string, b int) (c bool)", 1)
38         Foo("foo", 123) //@signature(",", "Foo(a string, b int) (c bool)", 0)
39         Foo("foo", 123) //@signature(" 1", "Foo(a string, b int) (c bool)", 1)
40         Foo("foo", 123) //@signature(")", "Foo(a string, b int) (c bool)", 1)
41
42         Bar(13.37, 0x13)       //@signature("13.37", "Bar(float64, ...byte)", 0)
43         Bar(13.37, 0x37)       //@signature("0x37", "Bar(float64, ...byte)", 1)
44         Bar(13.37, 1, 2, 3, 4) //@signature("4", "Bar(float64, ...byte)", 1)
45
46         fn := func(hi, there string) func(i int) rune {
47                 return func(int) rune { return 0 }
48         }
49
50         fn("hi", "there")    //@signature("hi", "fn(hi string, there string) func(i int) rune", 0)
51         fn("hi", "there")(1) //@signature("1", "func(i int) rune", 0)
52
53         fnPtr := &fn
54         (*fnPtr)("hi", "there") //@signature("hi", "func(hi string, there string) func(i int) rune", 0)
55
56         var fnIntf interface{} = Foo
57         fnIntf.(func(string, int) bool)("hi", 123) //@signature("123", "func(string, int) bool", 1)
58
59         (&bytes.Buffer{}).Next(2) //@signature("2", "Next(n int) []byte", 0)
60
61         myFunc := MyFunc(func(n int) string { return "" })
62         myFunc(123) //@signature("123", "myFunc(foo int) string", 0)
63
64         var ms myStruct
65         ms.foo(nil) //@signature("nil", "foo(e *json.Decoder) (*big.Int, error)", 0)
66
67         _ = make([]int, 1, 2) //@signature("2", "make(t Type, size ...int) Type", 1)
68
69         Foo(myFunc(123), 456) //@signature("myFunc", "Foo(a string, b int) (c bool)", 0)
70         Foo(myFunc(123), 456) //@signature("123", "myFunc(foo int) string", 0)
71
72         panic("oops!")            //@signature("oops", "panic(v interface{})", 0)
73         println("hello", "world") //@signature("world", "println(args ...Type)", 0)
74
75         Hello(func() {
76                 //@signature("//", "", 0)
77         })
78
79         AliasSlice()    //@signature(")", "AliasSlice(a []*Alias) (b Alias)", 0)
80         AliasMap()      //@signature(")", "AliasMap(a map[*Alias]StringAlias) (b map[*Alias]StringAlias, c map[*Alias]StringAlias)", 0)
81         OtherAliasMap() //@signature(")", "OtherAliasMap(a map[Alias]OtherAlias, b map[Alias]OtherAlias) map[Alias]OtherAlias", 0)
82 }
83
84 func Hello(func()) {}