statespace

package
v0.2.24 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

type Model[State any, Result any] struct {
	// contains filtered or unexported fields
}

Model implements a simple fuzz-style test framework. Rather than fuzz scalar values like property-based tests, this framework enumerates the subsets of a bounded, high-cardinality state space. Essentially, the framework will call the subject with every subset of the known mutations and assert on each invariant. Application order of mutations is randomized to avoid order-dependence without fully permuting the space (the implementation is very fast).

func Test

func Test[T any, TT any](fn func(T) TT) *Model[T, TT]

Test creates a new model for testing the given subject.

func (*Model[T, TT]) Evaluate

func (m *Model[T, TT]) Evaluate(t *testing.T)

Evaluate executes the test.

func (*Model[T, TT]) WithInitialState

func (m *Model[T, TT]) WithInitialState(fn func() T) *Model[T, TT]

func (*Model[T, TT]) WithInvariant

func (m *Model[T, TT]) WithInvariant(name string, fn func(state T, result TT) bool) *Model[T, TT]

WithInvariant appends a function that will be used to assert on the behavior of the subject for every subset of mutations.

func (*Model[T, TT]) WithMutation

func (m *Model[T, TT]) WithMutation(name string, fn func(T) T) *Model[T, TT]

WithMutation appends a function that will be applied to the state while evaluating the model.

Jump to

Keyboard shortcuts

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