MCPcopy Create free account
hub / github.com/golang/mobile / typeCheck

Function typeCheck

bind/bind_test.go:84–109  ·  view source on GitHub ↗
(t *testing.T, filename string, gopath string)

Source from the content-addressed store, hash-verified

82}
83
84func typeCheck(t *testing.T, filename string, gopath string) (*types.Package, *ast.File) {
85 f, err := parser.ParseFile(fset, filename, nil, parser.AllErrors|parser.ParseComments)
86 if err != nil {
87 t.Fatalf("%s: %v", filename, err)
88 }
89
90 pkgName := filepath.Base(filename)
91 pkgName = strings.TrimSuffix(pkgName, ".go")
92
93 // typecheck and collect typechecker errors
94 var conf types.Config
95 conf.Error = func(err error) {
96 t.Error(err)
97 }
98 if gopath != "" {
99 conf.Importer = importer.Default()
100 oldDefault := build.Default
101 defer func() { build.Default = oldDefault }()
102 build.Default.GOPATH = gopath
103 }
104 pkg, err := conf.Check(pkgName, fset, []*ast.File{f}, nil)
105 if err != nil {
106 t.Fatal(err)
107 }
108 return pkg, f
109}
110
111// diff runs the command "diff a b" and returns its output
112func diff(a, b string) string {

Callers 6

TestGenObjcFunction · 0.85
TestGenJavaFunction · 0.85
TestGenGoFunction · 0.85
TestGenGoJavaWrappersFunction · 0.85
TestGenGoObjcWrappersFunction · 0.85
TestCustomPrefixFunction · 0.85

Calls 2

DefaultMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected