assert

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 16 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

Overview

Package assert provides testing utilities

Index

Constants

View Source
const (
	// ErrInvalidTestExpression is raised when a check encounters a test value
	// that is not expected
	ErrInvalidTestExpression = "invalid test expression: %v"

	// ErrProperErrorNotRaised is raised when a panic is expected but not seen
	ErrProperErrorNotRaised = "proper error not raised, expected: %s"

	// ErrCannotMakeString is raised when a value can't be made into a string
	ErrCannotMakeString = "can't convert value to string"

	// ErrValueNotFound is raised when forced retrieval from an Object fails
	ErrValueNotFound = "value not found in object: %s"
)

Variables

This section is empty.

Functions

func GetRootSymbol

func GetRootSymbol(e encoder.Encoder, n data.Local) ale.Value

GetRootSymbol is a test helper that retrieves the value for a named symbol from the Encoder's global environment or dies trying

func GetTestEncoder

func GetTestEncoder() encoder.Encoder

GetTestEncoder returns a new Encoder, rooted at a test Namespace

func GetTestEnvironment

func GetTestEnvironment() *env.Environment

GetTestEnvironment returns an immutable root testing Environment

func GetTestNamespace

func GetTestNamespace() env.Namespace

GetTestNamespace returns a new anonymous namespace for testing purposes

Types

type Wrapper

type Wrapper struct {
	*testing.T
	*assert.Assertions
}

Wrapper wraps testify assertions to perform checking and conversion that is system-specific

func New

func New(t *testing.T) *Wrapper

New instantiates a new Wrapper instance from the specified test

func (*Wrapper) Compare

func (w *Wrapper) Compare(c data.Comparison, l data.Number, r data.Number)

Compare tests if the Comparison of two Numbers is correct

func (*Wrapper) Contains

func (w *Wrapper) Contains(expect string, expr ale.Value)

Contains check if the expected string is in the provided Value

func (*Wrapper) Equal

func (w *Wrapper) Equal(expect any, expr any)

Equal tests a Value for some kind of equality

func (*Wrapper) ErrorWith added in v0.3.0

func (w *Wrapper) ErrorWith(src string, err any)

func (*Wrapper) Eval

func (w *Wrapper) Eval(src string) (ale.Value, error)

func (*Wrapper) ExpectError added in v0.3.0

func (w *Wrapper) ExpectError(expected, err any)

func (*Wrapper) ExpectProgrammerError

func (w *Wrapper) ExpectProgrammerError(errStr string)

ExpectProgrammerError is used with defer to make sure a programmer error was triggered

func (*Wrapper) False

func (w *Wrapper) False(expr any)

False tests a Value for boolean false

func (*Wrapper) Identical

func (w *Wrapper) Identical(expect any, expr any)

Identical tests that two values are referentially identical

func (*Wrapper) Instructions

func (w *Wrapper) Instructions(expected, actual isa.Instructions)

Instructions test that two sets of Instructions are identical

func (*Wrapper) IsBound added in v0.3.0

func (w *Wrapper) IsBound(ns env.Namespace, n data.Local) ale.Value

func (*Wrapper) IsNotBound added in v0.3.0

func (w *Wrapper) IsNotBound(ns env.Namespace, n data.Local)

func (*Wrapper) IsNotDeclared added in v0.3.0

func (w *Wrapper) IsNotDeclared(ns env.Namespace, n data.Local)

func (*Wrapper) MustEncodedAs added in v0.3.0

func (w *Wrapper) MustEncodedAs(expected isa.Instructions, src data.String)

MustEncodedAs tests that a string generates the expected set of Instructions

func (*Wrapper) MustEval added in v0.3.0

func (w *Wrapper) MustEval(src string) ale.Value

MustEval will evaluate source code on behalf of the test framework

func (*Wrapper) MustEvalTo added in v0.3.0

func (w *Wrapper) MustEvalTo(src string, expect ale.Value)

MustEvalTo will evaluate source code and test for an expected result

func (*Wrapper) MustGet

func (w *Wrapper) MustGet(m data.Mapped, k ale.Value) ale.Value

MustGet retrieves a Value from a Mapped or explodes

func (*Wrapper) NotContains

func (w *Wrapper) NotContains(expect string, expr ale.Value)

NotContains checks if the expected string is not in the provided Value

func (*Wrapper) NotIdentical

func (w *Wrapper) NotIdentical(expect any, expr any)

NotIdentical tests that two values are not referentially identical

func (*Wrapper) Number

func (w *Wrapper) Number(expect float64, expr any)

Number tests a Value for numeric equality

func (*Wrapper) PanicWith

func (w *Wrapper) PanicWith(src string, err any)

PanicWith evaluates source code and expects a panic to happen

func (*Wrapper) String

func (w *Wrapper) String(expect string, expr any)

String tests a Value for string equality

func (*Wrapper) True

func (w *Wrapper) True(expr any)

True tests a Value for boolean true

Directories

Path Synopsis
Package helpers provides test helper functions
Package helpers provides test helper functions

Jump to

Keyboard shortcuts

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