github.com/jhump/golang-x-tools@v0.0.0-20220218190644-4958d6d39439/go/analysis/passes/buildssa/buildssa_test.go (about)

     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 buildssa_test
     6  
     7  import (
     8  	"fmt"
     9  	"os"
    10  	"testing"
    11  
    12  	"github.com/jhump/golang-x-tools/go/analysis/analysistest"
    13  	"github.com/jhump/golang-x-tools/go/analysis/passes/buildssa"
    14  )
    15  
    16  func Test(t *testing.T) {
    17  	testdata := analysistest.TestData()
    18  	result := analysistest.Run(t, testdata, buildssa.Analyzer, "a")[0].Result
    19  
    20  	ssainfo := result.(*buildssa.SSA)
    21  	got := fmt.Sprint(ssainfo.SrcFuncs)
    22  	want := `[a.Fib (a.T).fib]`
    23  	if got != want {
    24  		t.Errorf("SSA.SrcFuncs = %s, want %s", got, want)
    25  		for _, f := range ssainfo.SrcFuncs {
    26  			f.WriteTo(os.Stderr)
    27  		}
    28  	}
    29  }