assert

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package assert contains a system-specific wrapper for testify assertions

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"

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

	// ErrValueNotFound is raised when a 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) data.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 data.Value)

Contains check if the expected string is in the provided Value

func (*Wrapper) EncodesAs

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

EncodesAs tests that a string generates the expected set of Instructions

func (*Wrapper) Equal

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

Equal tests a Value for some kind of equality

func (*Wrapper) Eval

func (w *Wrapper) Eval(src string) data.Value

Eval will evaluate source code on behalf of the test framework

func (*Wrapper) EvalTo

func (w *Wrapper) EvalTo(src string, expect data.Value)

EvalTo will evaluate source code and test for an expected result

func (*Wrapper) ExpectNoPanic

func (w *Wrapper) ExpectNoPanic()

ExpectNoPanic is used with defer to make sure no error occurs

func (*Wrapper) ExpectPanic

func (w *Wrapper) ExpectPanic(err any)

ExpectPanic is used with a defer to make sure an error was triggered

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) MustGet

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

MustGet retrieves a Value from a Mapped or explodes

func (*Wrapper) NotContains

func (w *Wrapper) NotContains(expect string, expr data.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

Jump to

Keyboard shortcuts

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