Debian Codegraph @

go/analysis/passes/ctrlflow/ctrlflow_test.go

raw symbols SCIP
1 // Copyright 2018 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
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 // Perform a minimal smoke test on
20 // the result (CFG) computed by ctrlflow.
21 for _, result := range results {
22 cfgs := result.Result.(*ctrlflow.CFGs)
23
24 for _, decl := range result.Action.Package.Syntax[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.Action.Package.Fset.Position(decl.Pos()), decl.Name.Name)
29 }
30 }
31 }
32 }
33 }