libtesting

package
v1.61.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPackageName = "testing"

DefaultPackageName is the package name used by LoadPackage.

View Source
const DefaultSuiteSymbol = "test-suite"

Variables

This section is empty.

Functions

func LoadPackage

func LoadPackage(env *lisp.LEnv) *lisp.LVal

LoadPackage adds the testing package to env

Types

type Test

type Test struct {
	Fun  *lisp.LVal
	Name string
}

type TestSuite

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

TestSuite is an ordered set of named tests.

A TestSuite's own bookkeeping is safe for concurrent use, so one suite may be registered into, and read from, any number of environments at once. LoadPackage gives every environment its own suite, so the ordinary path never shares one, but NewTestSuite and EnvTestSuite are exported with no stated scope: an embedder that installs one suite into several runtimes is doing something the API permits. Evaluating a `test` or `benchmark` form writes the suite's maps, and two goroutines writing one Go map is `fatal error: concurrent map writes`, which is thrown by the runtime and cannot be recovered. The mutex below is what keeps that from being reachable. See issue #420.

What this does NOT promise is anything about running a registered test. A Test's Fun is a lambda closed over the environment that defined it, so evaluating it from a different runtime is environment sharing, which is a separate question from whether the suite is a safe container.

Template publication rejects suites, even empty ones. Template-based runners load this package and register their tests separately in each VM.

func EnvTestSuite

func EnvTestSuite(env *lisp.LEnv) *TestSuite

EnvTestSuite returns the suite installed in env, or nil if there is none. The suite is returned by pointer and is safe to use while other environments holding the same suite are evaluating.

"None" includes a runtime that never loaded this package at all. The map lookup is nil-checked because Registry.Package returns a nil *Package for an unregistered name and Package.Get dereferences pkg.symbols, so using it unchecked turned "does this runtime have a suite?" -- the question the nil return advertises -- into a nil pointer dereference in the host. See issue #425.

func NewTestSuite

func NewTestSuite() *TestSuite

NewTestSuite returns an empty suite. The result may be installed into any number of environments and used from all of them concurrently.

func (*TestSuite) Add

func (s *TestSuite) Add(t *Test) error

func (*TestSuite) AddBenchmark added in v1.13.0

func (s *TestSuite) AddBenchmark(b *Test) error

func (*TestSuite) Benchmark added in v1.13.0

func (s *TestSuite) Benchmark(i int) *Test

func (*TestSuite) Benchmarks added in v1.13.0

func (s *TestSuite) Benchmarks() []string

func (*TestSuite) CloneNative added in v1.61.0

func (s *TestSuite) CloneNative() interface{}

CloneNative copies registry bookkeeping for within-VM value copies. Test functions are retained by pointer and still belong to their original VM. This does not transfer a populated suite across runtimes: Template rejects suites, and each VM must register and execute its own tests.

func (*TestSuite) Len

func (s *TestSuite) Len() int

func (*TestSuite) MacroAssertEqual

func (s *TestSuite) MacroAssertEqual(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

func (*TestSuite) MacroAssertNil

func (s *TestSuite) MacroAssertNil(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

func (*TestSuite) MacroAssertNot

func (s *TestSuite) MacroAssertNot(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

func (*TestSuite) MacroAssertNotNil

func (s *TestSuite) MacroAssertNotNil(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

func (*TestSuite) MacroAssertNumEq

func (s *TestSuite) MacroAssertNumEq(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

func (*TestSuite) MacroAssertStringEq

func (s *TestSuite) MacroAssertStringEq(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

func (*TestSuite) MacroBenchmarkSimple added in v1.13.0

func (s *TestSuite) MacroBenchmarkSimple(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

func (*TestSuite) MacroTestLet

func (s *TestSuite) MacroTestLet(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

func (*TestSuite) MacroTestLetSeq

func (s *TestSuite) MacroTestLetSeq(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

func (*TestSuite) Macros

func (s *TestSuite) Macros() []*libutil.Builtin

func (*TestSuite) OpBenchmark added in v1.13.0

func (s *TestSuite) OpBenchmark(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

func (*TestSuite) OpTest

func (s *TestSuite) OpTest(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

func (*TestSuite) Ops

func (s *TestSuite) Ops() []*libutil.Builtin

Ops returns registration operations that resolve testing:test-suite in the calling environment. Embedders must install that binding as well as the ops; the receiver is never used as a fallback registry.

func (*TestSuite) Test

func (s *TestSuite) Test(i int) *Test

func (*TestSuite) Tests added in v1.13.0

func (s *TestSuite) Tests() []string

Jump to

Keyboard shortcuts

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