Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / tools@v0.0.0-20201028153306-37f0764111ff / go / analysis / passes / ctrlflow / ctrlflow_test.go
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
18         // load testdata/src/a/a.go
19         results := analysistest.Run(t, testdata, ctrlflow.Analyzer, "a")
20
21         // Perform a minimal smoke test on
22         // the result (CFG) computed by ctrlflow.
23         for _, result := range results {
24                 cfgs := result.Result.(*ctrlflow.CFGs)
25
26                 for _, decl := range result.Pass.Files[0].Decls {
27                         if decl, ok := decl.(*ast.FuncDecl); ok && decl.Body != nil {
28                                 if cfgs.FuncDecl(decl) == nil {
29                                         t.Errorf("%s: no CFG for func %s",
30                                                 result.Pass.Fset.Position(decl.Pos()), decl.Name.Name)
31                                 }
32                         }
33                 }
34         }
35 }