tests

Imports

Imports #

_ "embed"
"go/ast"
"go/token"
"go/types"
"regexp"
"strings"
"unicode"
"unicode/utf8"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/passes/internal/analysisutil"

Constants & Variables

Analyzer var #

var Analyzer = *ast.UnaryExpr

acceptedFuzzTypes var #

var acceptedFuzzTypes = []types.Type{...}

doc var #

go:embed doc.go

var doc string

outputRe var #

This pattern is taken from /go/src/go/doc/example.go

var outputRe = *ast.CallExpr

Structs

commentMetadata struct #

type commentMetadata struct {
isOutput bool
pos token.Pos
}

tokenRange struct #

type tokenRange struct {
p token.Pos
e token.Pos
}

Functions

End method #

func (r tokenRange) End() token.Pos

Pos method #

func (r tokenRange) Pos() token.Pos

checkAddCalls function #

checkAddCalls checks that the arguments of f.Add calls have the same number and type of arguments as the signature of the function passed to (*testing.F).Fuzz

func checkAddCalls(pass *analysis.Pass, fn *ast.FuncDecl, params *types.Tuple)

checkExampleName function #

func checkExampleName(pass *analysis.Pass, fn *ast.FuncDecl)

checkExampleOutput function #

func checkExampleOutput(pass *analysis.Pass, fn *ast.FuncDecl, fileComments []*ast.CommentGroup)

checkFuzz function #

checkFuzz checks the contents of a fuzz function.

func checkFuzz(pass *analysis.Pass, fn *ast.FuncDecl)

checkFuzzCall function #

checkFuzzCall checks the arguments of f.Fuzz() calls: 1. f.Fuzz() should call a function and it should be of type (*testing.F).Fuzz(). 2. The called function in f.Fuzz(func(){}) should not return result. 3. First argument of func() should be of type *testing.T 4. Second argument onwards should be of type []byte, string, bool, byte, rune, float32, float64, int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64 5. func() must not call any *F methods, e.g. (*F).Log, (*F).Error, (*F).Skip The only *F methods that are allowed in the (*F).Fuzz function are (*F).Failed and (*F).Name. Returns the list of parameters to the fuzz function, if they are valid fuzz parameters.

func checkFuzzCall(pass *analysis.Pass, fn *ast.FuncDecl) (params *types.Tuple)

checkTest function #

func checkTest(pass *analysis.Pass, fn *ast.FuncDecl, prefix string)

formatAcceptedFuzzType function #

func formatAcceptedFuzzType() string

isAcceptedFuzzType function #

Validate that fuzz target function's arguments are of accepted types.

func isAcceptedFuzzType(paramType types.Type) bool

isExampleSuffix function #

func isExampleSuffix(s string) bool

isFuzzTargetDot function #

isFuzzTargetDot reports whether call is (*testing.F).().

func isFuzzTargetDot(pass *analysis.Pass, call *ast.CallExpr, name string) bool

isFuzzTargetDotAdd function #

isFuzzTargetDotAdd reports whether call is (*testing.F).Add().

func isFuzzTargetDotAdd(pass *analysis.Pass, call *ast.CallExpr) bool

isFuzzTargetDotFuzz function #

isFuzzTargetDotFuzz reports whether call is (*testing.F).Fuzz().

func isFuzzTargetDotFuzz(pass *analysis.Pass, call *ast.CallExpr) bool

isTestParam function #

func isTestParam(typ ast.Expr, wantType string) bool

isTestSuffix function #

func isTestSuffix(name string) bool

isTestingType function #

func isTestingType(typ types.Type, testingType string) bool

lookup function #

func lookup(pkg *types.Package, name string) []types.Object

run function #

func run(pass *analysis.Pass) (interface{}, error)

validateFuzzArgs function #

Validate the arguments of fuzz target.

func validateFuzzArgs(pass *analysis.Pass, params *types.Tuple, expr ast.Expr) bool

Generated with Arrow