...
1
2
3
4
5 package ctrlflow_test
6
7 import (
8 "go/ast"
9 "testing"
10
11 "golang.org/x/tools/go/analysis/analysistest"
12 "golang.org/x/tools/go/analysis/passes/ctrlflow"
13 )
14
15 func Test(t *testing.T) {
16 testdata := analysistest.TestData()
17 results := analysistest.Run(t, testdata, ctrlflow.Analyzer, "a", "typeparams")
18
19
20
21 for _, result := range results {
22 cfgs := result.Result.(*ctrlflow.CFGs)
23
24 for _, decl := range result.Pass.Files[0].Decls {
25 if decl, ok := decl.(*ast.FuncDecl); ok && decl.Body != nil {
26 if cfgs.FuncDecl(decl) == nil {
27 t.Errorf("%s: no CFG for func %s",
28 result.Pass.Fset.Position(decl.Pos()), decl.Name.Name)
29 }
30 }
31 }
32 }
33 }
34
View as plain text