test

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpectParse

func ExpectParse(t *testing.T, input string, fn ExpectedFn, opt ...ExpectOpt)

func ExpectParseError

func ExpectParseError(t *testing.T, input string, e ...[2]string)

func ExpectParseExpr

func ExpectParseExpr(t *testing.T, input string, expr node.Expr, opt ...ExpectOpt)

func ExpectParseMixed

func ExpectParseMixed(t *testing.T, input string, fn ExpectedFn)

func ExpectParseMode

func ExpectParseMode(t *testing.T, mode parser.Mode, input string, fn ExpectedFn, opt ...ExpectOpt)

func ExpectParseStmt

func ExpectParseStmt(t *testing.T, input string, stmt node.Stmt, opt ...ExpectOpt)

func ExpectParseString

func ExpectParseString(t *testing.T, input, expected string)

func ExpectParseStringMixed

func ExpectParseStringMixed(t *testing.T, input, expected string)

func ExpectParseStringMode

func ExpectParseStringMode(t *testing.T, mode parser.Mode, input, expected string)

func ExpectParseStringModeT

func ExpectParseStringModeT(t *testing.T, mode parser.Mode, input, expected string, typ any)

func ExpectParseStringT

func ExpectParseStringT(t *testing.T, input, expected string, typ any)

Types

type ExpectOpt

type ExpectOpt func(ctx *ParseContext)
var OptParseCharAsString ExpectOpt = func(ctx *ParseContext) {
	ctx.ScannerOptions.Mode |= parser.ScanCharAsString
}

func PostTest

func PostTest(do func(t *testing.T, f *source.File, pos func(line, column int) source.Pos)) ExpectOpt

type ExpectedFn

type ExpectedFn func(pos Pfn) []node.Stmt // callback function to return expected results

type File

type File struct {
	// contains filtered or unexported fields
}

func NewFile

func NewFile(t *testing.T, actual *parser.File) *File

func (*File) Equal

func (f *File) Equal(expected, actual any, msgAndArgs ...any)

func (*File) EqualDictElements

func (f *File) EqualDictElements(
	expected, actual []*node.DictElementLit,
)

func (*File) EqualExpr

func (f *File) EqualExpr(expected, actual node.Expr)

func (*File) EqualExprs

func (f *File) EqualExprs(expected, actual []node.Expr)

func (*File) EqualFuncParams

func (f *File) EqualFuncParams(expected, actual *node.FuncParams)

func (*File) EqualFuncType

func (f *File) EqualFuncType(expected, actual *node.FuncType)

func (*File) EqualNamedArgs

func (f *File) EqualNamedArgs(expected, actual *node.NamedArgsList)

func (*File) EqualNamedArgsNames

func (f *File) EqualNamedArgsNames(expected, actual []*node.NamedArgExpr)

func (*File) EqualStmt

func (f *File) EqualStmt(expected, actual node.Stmt)

func (*File) EqualStmts

func (f *File) EqualStmts(expected, actual []node.Stmt)

func (*File) EqualTypedIdents

func (f *File) EqualTypedIdents(expected, actual []*node.TypedIdentExpr)

func (*File) Expect

func (f *File) Expect(fn ExpectedFn, post ...PostFileCallback) *File

func (*File) File

func (f *File) File() *parser.File

type ParseContext

type ParseContext struct {
	ParserOptions  *parser.ParserOptions
	ScannerOptions *parser.ScannerOptions
	PostTests      []PostFileCallback
}

func (*ParseContext) PostTest

func (c *ParseContext) PostTest(f func(t *testing.T, f *source.File, pos func(line, column int) source.Pos))

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

func New

func New(t *testing.T, input string) *Parser

func (*Parser) Code

func (p *Parser) Code(s string, opt ...node.CodeOption) *Parser

func (*Parser) Error

func (p *Parser) Error(e ...[2]string)

func (*Parser) File

func (p *Parser) File() *File

func (*Parser) FormattedCalcCode

func (p *Parser) FormattedCalcCode(s string, maxColumns int, opt ...node.CodeOption) *Parser

FormattedCalcCode formats with the NEW_LINE_CALC column-aware mode and the given max column budget.

func (*Parser) FormattedCode

func (p *Parser) FormattedCode(s string, opt ...node.CodeOption) *Parser

func (*Parser) GetParserOptions

func (p *Parser) GetParserOptions() *parser.ParserOptions

func (*Parser) GetScannerOptions

func (p *Parser) GetScannerOptions() *parser.ScannerOptions

func (*Parser) IndentedCode

func (p *Parser) IndentedCode(s string, opt ...node.CodeOption) *Parser

func (*Parser) ParseSource

func (p *Parser) ParseSource(
	trace io.Writer,
) (*parser.File, error)

func (*Parser) Run

func (p *Parser) Run(cb ...func(pt *Parser)) *Parser

func (*Parser) Stmts

func (p *Parser) Stmts(fn ExpectedFn, post ...PostFileCallback) *Parser

func (*Parser) String

func (p *Parser) String(s string) *Parser

func (*Parser) Type

func (p *Parser) Type(v any) *Parser

func (*Parser) WithCodeOptions

func (p *Parser) WithCodeOptions(opt ...node.CodeOption) *Parser

func (*Parser) WithMixed

func (p *Parser) WithMixed() *Parser

func (*Parser) WithMode

func (p *Parser) WithMode(m parser.Mode) *Parser

func (*Parser) WithParserOptions

func (p *Parser) WithParserOptions(f func(opt *parser.ParserOptions)) *Parser

func (*Parser) WithScannerOptions

func (p *Parser) WithScannerOptions(f func(opt *parser.ScannerOptions)) *Parser

type Pfn

type Pfn func(int, int) source.Pos // position conversion function

type PostFileCallback

type PostFileCallback func(t *testing.T, f *source.File, pos func(line, column int) source.Pos)

type Tracer

type Tracer struct {
	Out []string
}

func (*Tracer) Write

func (o *Tracer) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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