srctesting

package
v1.17.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2022 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package srctesting contains common helpers for unit testing source code analysis and transformation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(t *testing.T, fset *token.FileSet, files ...*ast.File) (*types.Info, *types.Package)

Check type correctness of the provided AST.

Assumes "test" package import path. Fails the test if type checking fails. Provided AST is expected not to have any imports.

func Parse

func Parse(t *testing.T, fset *token.FileSet, src string) *ast.File

Parse source from the string and return complete AST.

Assumes source file name `test.go`. Fails the test on parsing error.

func ParseFuncDecl

func ParseFuncDecl(t *testing.T, src string) *ast.FuncDecl

ParseFuncDecl parses source with a single function defined and returns the function AST.

Fails the test if there isn't exactly one function declared in the source.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL