testastguard

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package testastguard is the shared syntax-census toolkit for structural "X is the only mechanism" test guards: parse a file, find a FuncDecl, and position test call sites against its body span. A new pin is a ~10-line census over these primitives instead of a hand-rolled go/parser walk (twentyfifth-dispatch §e2: extracted from the webui headermatrix and executor redaction guards).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallNames

func CallNames(node ast.Node) []string

CallNames returns the callee names of every call inside node: bare idents by name, selector calls by the selected name.

func InSpan

func InSpan(start, end, pos token.Pos) bool

InSpan reports whether pos lies within [start, end).

func IsMaps

func IsMaps(call *ast.CallExpr) bool

IsMaps reports whether the call's receiver identifier is "maps" (the maps.Copy / maps.Clone census qualifier).

Types

type File

type File struct {
	FSet *token.FileSet
	AST  *ast.File
	Path string
}

File is a parsed Go source file with its position table.

func Parse

func Parse(t testing.TB, path string) *File

Parse reads and parses path, failing t on either error.

func (*File) CensusCalls

func (f *File) CensusCalls(match func(call *ast.CallExpr) bool, visit func(call *ast.CallExpr))

CensusCalls visits every CallExpr in the file for which match returns true.

func (*File) FuncBody

func (f *File) FuncBody(t testing.TB, name string) ast.Node

FuncBody returns the body of the named top-level FuncDecl, failing t when the function (or its body) is absent — a census over a missing mechanism is silently vacuous, so that failure is loud.

func (*File) FuncDecls

func (f *File) FuncDecls(include func(name string) bool, visit func(name string, body ast.Node))

FuncDecls iterates the file's top-level FuncDecls that have a body and whose name passes include.

Jump to

Keyboard shortcuts

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