1 // Package signature has tests for signature help.
10 func Foo(a string, b int) (c bool) {
14 func Bar(float64, ...byte) {
17 type myStruct struct{}
19 func (*myStruct) foo(e *json.Decoder) (*big.Int, error) {
25 type MyFunc func(foo int) string
29 type StringAlias = string
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 }
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)
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)
46 fn := func(hi, there string) func(i int) rune {
47 return func(int) rune { return 0 }
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)
54 (*fnPtr)("hi", "there") //@signature("hi", "func(hi string, there string) func(i int) rune", 0)
56 var fnIntf interface{} = Foo
57 fnIntf.(func(string, int) bool)("hi", 123) //@signature("123", "func(string, int) bool", 1)
59 (&bytes.Buffer{}).Next(2) //@signature("2", "Next(n int) []byte", 0)
61 myFunc := MyFunc(func(n int) string { return "" })
62 myFunc(123) //@signature("123", "myFunc(foo int) string", 0)
65 ms.foo(nil) //@signature("nil", "foo(e *json.Decoder) (*big.Int, error)", 0)
67 _ = make([]int, 1, 2) //@signature("2", "make(t Type, size ...int) Type", 1)
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)
72 panic("oops!") //@signature("oops", "panic(v interface{})", 0)
73 println("hello", "world") //@signature("world", "println(args ...Type)", 0)
76 //@signature("//", "", 0)
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)