-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfixtures_test.go
133 lines (85 loc) · 1.85 KB
/
fixtures_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package compat
import (
"go/types"
"golang.org/x/tools/go/packages"
)
func init() {
conf := &packages.Config{
Mode: goLoadMode,
Tests: true,
}
loadedPackages, err := packages.Load(conf, "file=fixtures_test.go")
if err != nil {
panic(err)
}
if len(loadedPackages) != 1 {
panic("expected a single loaded package")
}
FixtureObjects = make(map[string]types.Object)
scope := loadedPackages[0].Types.Scope()
for _, name := range scope.Names() {
obj := scope.Lookup(name)
FixtureObjects[obj.Name()] = obj
}
}
var FixturePackage *packages.Package
var FixtureObjects map[string]types.Object
type StructA1 struct {
}
type StructA2 struct {
Field1 string
}
type StructA3 struct {
Field1 string
Field2 string
}
type StructA4 struct {
Field1 string
Field2 int
}
type StructA5 struct {
Field1 string
Field2 int
Field3 string
}
type TypeAlias1 = int
type TypeAlias2 = string
type TypeAlias3 = StructA3
type TypeAlias4 = StructA5
type Named1 int
type Named2 string
type Named3 StructA3
type Named4 StructA5
func Func1() {}
func Func2(arg1 string) {}
func Func3(arg1 string, arg2 string) {}
func Func4(arg1 string, arg2 int) {}
func Func5(arg1 string, arg2 int) string { return "" }
func Func6(arg1 string, arg2 int) int { return 0 }
func Func7(arg1 string, arg2 int) (string, int) { return "", 0 }
func Func8(arg1 ...string) {}
func Func9(arg1 StructA5) {}
type StructB1 struct{}
func (StructB1) Func1() {}
func (StructB1) func1() {}
type StructB2 struct{}
func (StructB2) Func1(arg1 int) {}
func (StructB2) func1() {}
var Array1 [20]int
var ChanRead1 <-chan int
var Map1 map[int]string
var Pointer1 *int
const Const1 = "foo"
var VarInit1 = "foo"
var VarInit2 *string = nil
var VarInit3 = ""
type Interface1 interface{}
type Interface2 interface {
F()
}
type Interface3 interface {
F(s string)
}
type Interface4 interface {
f()
}