spec

package
v2.0.0-alpha.13 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compile

func Compile(expression string, level ...compiler.OptimizationLevel) (*bytecode.Program, error)

func Exec

func Exec(p *bytecode.Program, raw bool, opts ...vm.EnvironmentOption) (any, error)

func ExecInstance

func ExecInstance(instance *vm.VM, raw bool, env *vm.Environment) (any, error)

func ExecWith

func ExecWith(p *bytecode.Program, raw bool, vmOpts []vm.Option, opts ...vm.EnvironmentOption) (any, error)

func ForWhileHelpers

func ForWhileHelpers() runtime.FunctionDefs

func PrintDebug

func PrintDebug(t *testing.T, name string, prog *bytecode.Program)

func PrintError

func PrintError(t *testing.T, err error)

func Run

func Run(p *bytecode.Program, opts ...vm.EnvironmentOption) ([]byte, error)

func RunBenchmark

func RunBenchmark(b *testing.B, expression string, opts ...vm.EnvironmentOption)

func RunBenchmarkWith

func RunBenchmarkWith(b *testing.B, c *compiler.Compiler, expression string, opts ...vm.EnvironmentOption)

func RunBenchmarkWithOptimization

func RunBenchmarkWithOptimization(b *testing.B, expression string, level compiler.OptimizationLevel, opts ...vm.EnvironmentOption)

func RunInstance

func RunInstance(instance *vm.VM, env *vm.Environment) ([]byte, error)

func RunOutputBenchmark

func RunOutputBenchmark(b *testing.B, expression string, opts ...vm.EnvironmentOption)

func RunOutputBenchmarkWith

func RunOutputBenchmarkWith(b *testing.B, c *compiler.Compiler, expression string, opts ...vm.EnvironmentOption)

func RunOutputBenchmarkWithOptimization

func RunOutputBenchmarkWithOptimization(b *testing.B, expression string, level compiler.OptimizationLevel, opts ...vm.EnvironmentOption)

func RunResultBenchmark

func RunResultBenchmark(b *testing.B, expression string, opts ...vm.EnvironmentOption)

func RunResultBenchmarkWith

func RunResultBenchmarkWith(b *testing.B, c *compiler.Compiler, expression string, opts ...vm.EnvironmentOption)

func RunResultBenchmarkWithOptimization

func RunResultBenchmarkWithOptimization(b *testing.B, expression string, level compiler.OptimizationLevel, opts ...vm.EnvironmentOption)

func RunWith

func RunWith(p *bytecode.Program, vmOpts []vm.Option, opts ...vm.EnvironmentOption) ([]byte, error)

func StateFn

func StateFn[T any](fn runtime.Function, factory func(ctx context.Context) T) runtime.Function

func Stdlib

func Stdlib() runtime.Namespace

func WithParam

func WithParam(name string, value any) vm.EnvironmentOption

Types

type BaseSpec

type BaseSpec struct {
	Input       Input
	Description string
	SkipInfo    Skip
	DebugOutput bool
}

func NewBaseSpec

func NewBaseSpec(expr string, desc ...string) BaseSpec

func NewBaseSpecWith

func NewBaseSpecWith(input Input, desc ...string) BaseSpec

func (BaseSpec) Debug

func (s BaseSpec) Debug() BaseSpec

func (BaseSpec) Merge

func (s BaseSpec) Merge(other BaseSpec) BaseSpec

func (BaseSpec) Skip

func (s BaseSpec) Skip(reason ...string) BaseSpec

func (BaseSpec) String

func (s BaseSpec) String() string

func (BaseSpec) Suffix

func (s BaseSpec) Suffix(suffix string) BaseSpec

func (BaseSpec) SuiteName

func (s BaseSpec) SuiteName(suite string) string

type CompileInfo

type CompileInfo struct {
	Outcomes
}

func (CompileInfo) Merge

func (c CompileInfo) Merge(other CompileInfo) CompileInfo

type ExecInfo

type ExecInfo struct {
	Outcomes
	Env       []vm.EnvironmentOption
	VM        []vm.Option
	RawOutput bool
}

func (ExecInfo) Merge

func (e ExecInfo) Merge(other ExecInfo) ExecInfo

type Expectation

type Expectation struct {
	Value     any
	Assertion assert.Assertion
}

func NewExpectation

func NewExpectation(fn assert.Assertion, val ...any) Expectation

func (Expectation) Assert

func (exp Expectation) Assert(t *testing.T, actual any)

func (Expectation) Defined

func (exp Expectation) Defined() bool

func (Expectation) Merge

func (exp Expectation) Merge(other Expectation) Expectation

type ExpectationBuilder

type ExpectationBuilder[T any] struct {
	// contains filtered or unexported fields
}

func NewExpectationBuilder

func NewExpectationBuilder[T any](ret *T, base func(*T) *Spec) ExpectationBuilder[T]

func (ExpectationBuilder[T]) Compile

func (b ExpectationBuilder[T]) Compile(fn assert.Assertion, val ...any) T

func (ExpectationBuilder[T]) CompileError

func (b ExpectationBuilder[T]) CompileError(fn assert.Assertion, val ...any) T

func (ExpectationBuilder[T]) Exec

func (b ExpectationBuilder[T]) Exec(fn assert.Assertion, val ...any) T

func (ExpectationBuilder[T]) ExecError

func (b ExpectationBuilder[T]) ExecError(fn assert.Assertion, val ...any) T

type FnState

type FnState[T any] interface {
	Get() T
	Set(value T)
}

func GetFnState

func GetFnState[T any](ctx context.Context) FnState[T]

type Input

type Input struct {
	Source     ProgramSource
	Expression string
}

func NewExpressionInput

func NewExpressionInput(expression string) Input

func NewProgramInput

func NewProgramInput(program *bytecode.Program, name ...string) Input

func NewProgramSourceInput

func NewProgramSourceInput(source ProgramSource) Input

func (Input) Merge

func (i Input) Merge(other Input) Input

func (Input) ResolveProgram

func (i Input) ResolveProgram(name string, c *compiler.Compiler) (*bytecode.Program, error)

func (Input) String

func (i Input) String() string

type Outcomes

type Outcomes struct {
	Result Expectation
	Error  Expectation
}

func (Outcomes) Merge

func (o Outcomes) Merge(other Outcomes) Outcomes

type ProgramBuilder

type ProgramBuilder func(name string, c *compiler.Compiler) (*bytecode.Program, error)

type ProgramSource

type ProgramSource struct {
	Build ProgramBuilder
	Name  string
}

type Runner

type Runner struct {
	Name     string
	Compiler *compiler.Compiler
	Env      []vm.EnvironmentOption
}

func NewRunner

func NewRunner(suite string, opts ...compiler.Option) *Runner

func (*Runner) Run

func (r *Runner) Run(t *testing.T, specs []Spec)

type Sequence

type Sequence struct {
	Env   []vm.EnvironmentOption
	VM    []vm.Option
	Steps []SequenceStep
	Base  BaseSpec
}

func NewSequence

func NewSequence(expression string, desc ...string) Sequence

type SequenceRunner

type SequenceRunner struct {
	Name     string
	Compiler *compiler.Compiler
	Env      []vm.EnvironmentOption
}

func NewSequenceRunner

func NewSequenceRunner(suite string, opts ...compiler.Option) *SequenceRunner

func (*SequenceRunner) Run

func (r *SequenceRunner) Run(t *testing.T, sequences []Sequence)

type SequenceStep

type SequenceStep struct {
	Result     Expectation
	Error      Expectation
	Panic      Expectation
	EnvFactory func() (*vm.Environment, error)
	Name       string
	Env        []vm.EnvironmentOption
}

func ErrorStep

func ErrorStep(name string, fn assert.Assertion, val ...any) SequenceStep

func PanicStep

func PanicStep(name string, fn assert.Assertion, val ...any) SequenceStep

func ResultStep

func ResultStep(name string, fn assert.Assertion, val ...any) SequenceStep

type Skip

type Skip struct {
	Reason string
	Active bool
}

type Spec

type Spec struct {
	Base    BaseSpec
	Compile CompileInfo
	Exec    ExecInfo
}

func Compose

func Compose(base Spec, extenders ...Spec) Spec

func NewProgramSpec

func NewProgramSpec(expression *bytecode.Program, desc ...string) Spec

func NewSpec

func NewSpec(expression string, desc ...string) Spec

func NewSpecWith

func NewSpecWith(input Input, desc ...string) Spec

func (Spec) Debug

func (s Spec) Debug() Spec

func (Spec) Env

func (s Spec) Env(o ...vm.EnvironmentOption) Spec

func (Spec) Expect

func (s Spec) Expect() ExpectationBuilder[Spec]

func (Spec) Merge

func (s Spec) Merge(other Spec) Spec

func (Spec) Raw

func (s Spec) Raw() Spec

func (Spec) Skip

func (s Spec) Skip(reason ...string) Spec

func (Spec) String

func (s Spec) String() string

func (Spec) Suffix

func (s Spec) Suffix(suffix string) Spec

func (Spec) SuiteName

func (s Spec) SuiteName(suite string) string

func (Spec) VM

func (s Spec) VM(o ...vm.Option) Spec

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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