testing

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2026 License: Apache-2.0 Imports: 8 Imported by: 1 module, 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

View Source
var Array = base.Assertion{
	DefaultMessage: func(_ []core.Value) string {
		return "be array"
	},
	MinArgs: 1,
	MaxArgs: 2,
	Fn: func(_ context.Context, args []core.Value) (bool, error) {
		return args[0].Type() == types.Array, nil
	},
}

ARRAY asserts that value is a array type. @param {Any} actual - Value to test. @param {String} [message] - Message to display on error.

View Source
var Binary = base.Assertion{
	DefaultMessage: func(_ []core.Value) string {
		return "be binary"
	},
	MinArgs: 1,
	MaxArgs: 2,
	Fn: func(_ context.Context, args []core.Value) (bool, error) {
		return args[0].Type() == types.Binary, nil
	},
}

BINARY asserts that value is a binary type. @param {Any} actual - Value to test. @param {String} [message] - Message to display on error.

View Source
var DateTime = base.Assertion{
	DefaultMessage: func(_ []core.Value) string {
		return "be datetime"
	},
	MinArgs: 1,
	MaxArgs: 2,
	Fn: func(_ context.Context, args []core.Value) (bool, error) {
		return args[0].Type() == types.DateTime, nil
	},
}

DATETIME asserts that value is a datetime type. @param {Any} actual - Value to test. @param {String} [message] - Message to display on error.

View Source
var Empty = base.Assertion{
	DefaultMessage: func(_ []core.Value) string {
		return "be empty"
	},
	MinArgs: 1,
	MaxArgs: 2,
	Fn: func(ctx context.Context, args []core.Value) (bool, error) {
		size, err := collections.Length(ctx, args[0])

		if err != nil {
			return false, err
		}

		return values.ToInt(size) == 0, nil
	},
}

EMPTY asserts that the target does not contain any values. @param {Measurable | Binary | Object | Any[] | String} actual - Value to test. @param {String} [message] - Message to display on error.

View Source
var Equal = base.Assertion{
	DefaultMessage: func(args []core.Value) string {
		return fmt.Sprintf("be %s %s", base.EqualOp, base.FormatValue(args[1]))
	},
	MinArgs: 2,
	MaxArgs: 3,
	Fn: func(_ context.Context, args []core.Value) (bool, error) {
		return base.EqualOp.Compare(args)
	},
}

EQUAL asserts equality of actual and expected values. @param {Any} actual - Actual value. @param {Any} expected - Expected value. @param {String} [message] - Message to display on error.

View Source
var Fail = base.Assertion{
	DefaultMessage: func(_ []core.Value) string {
		return "not fail"
	},
	MinArgs: 0,
	MaxArgs: 1,
	Fn: func(_ context.Context, _ []core.Value) (bool, error) {
		return false, nil
	},
}

FAIL returns an error. @param {String} [message] - Message to display on error.

View Source
var False = base.Assertion{
	DefaultMessage: func(_ []core.Value) string {
		return fmt.Sprintf("be %s", base.FormatValue(values.False))
	},
	MinArgs: 1,
	MaxArgs: 2,
	Fn: func(_ context.Context, args []core.Value) (bool, error) {
		return args[0] == values.False, nil
	},
}

FALSE asserts that value is false. @param {Any}actual - Value to test. @param {String} [message] - Message to display on error.

View Source
var Float = base.Assertion{
	DefaultMessage: func(_ []core.Value) string {
		return "be float"
	},
	MinArgs: 1,
	MaxArgs: 2,
	Fn: func(_ context.Context, args []core.Value) (bool, error) {
		return args[0].Type() == types.Float, nil
	},
}

FLOAT asserts that value is a float type. @param {Any} actual - Value to test. @param {String} [message] - Message to display on error.

View Source
var Gt = base.Assertion{
	DefaultMessage: func(args []core.Value) string {
		return fmt.Sprintf("be %s %s", base.GreaterOp, base.FormatValue(args[1]))
	},
	MinArgs: 2,
	MaxArgs: 3,
	Fn: func(_ context.Context, args []core.Value) (bool, error) {
		return base.GreaterOp.Compare(args)
	},
}

GT asserts that an actual value is greater than an expected one. @param {Any} actual - Actual value. @param {Any} expected - Expected value. @param {String} [message] - Message to display on error.

View Source
var Gte = base.Assertion{
	DefaultMessage: func(args []core.Value) string {
		return fmt.Sprintf("be %s %s", base.GreaterOrEqualOp, base.FormatValue(args[1]))
	},
	MinArgs: 2,
	MaxArgs: 3,
	Fn: func(_ context.Context, args []core.Value) (bool, error) {
		return base.GreaterOrEqualOp.Compare(args)
	},
}

GTE asserts that an actual value is greater than or equal to an expected one. @param {Any} actual - Actual value. @param {Any} expected - Expected value. @param {String} [message] - Message to display on error.

View Source
var Include = base.Assertion{
	DefaultMessage: func(args []core.Value) string {
		return fmt.Sprintf("include %s", base.FormatValue(args[1]))
	},
	MinArgs: 2,
	MaxArgs: 3,
	Fn: func(ctx context.Context, args []core.Value) (bool, error) {
		haystack := args[0]
		needle := args[1]

		out, err := collections.Includes(ctx, haystack, needle)

		if err != nil {
			return false, err
		}

		return out.Compare(values.True) == 0, nil
	},
}

INCLUDE asserts that haystack includes needle. @param {String | Array | Object | Iterable} actual - Haystack value. @param {Any} expected - Expected value. @param {String} [message] - Message to display on error.

View Source
var Int = base.Assertion{
	DefaultMessage: func(_ []core.Value) string {
		return "be int"
	},
	MinArgs: 1,
	MaxArgs: 2,
	Fn: func(_ context.Context, args []core.Value) (bool, error) {
		return args[0].Type() == types.Int, nil
	},
}

INT asserts that value is a int type. @param {Any} actual - Actual value. @param {String} [message] - Message to display on error.

View Source
var Len = base.Assertion{
	DefaultMessage: func(args []core.Value) string {
		return fmt.Sprintf("has size %s", args[1])
	},
	MinArgs: 2,
	MaxArgs: 3,
	Fn: func(ctx context.Context, args []core.Value) (bool, error) {
		col := args[0]
		size := args[1]

		out, err := collections.Length(ctx, col)

		if err != nil {
			return false, err
		}

		return out.Compare(size) == 0, nil
	},
}

LEN asserts that a measurable value has a length or size with the expected value. @param {Measurable} actual - Measurable value. @param {Int} length - Target length. @param {String} [message] - Message to display on error.

View Source
var Lt = base.Assertion{
	DefaultMessage: func(args []core.Value) string {
		return fmt.Sprintf("be %s %s", base.LessOp, base.FormatValue(args[1]))
	},
	MinArgs: 2,
	MaxArgs: 3,
	Fn: func(_ context.Context, args []core.Value) (bool, error) {
		return base.LessOp.Compare(args)
	},
}

LT asserts that an actual value is lesser than an expected one. @param {Any} actual - Actual value. @param {Any} expected - Expected value. @param {String} [message] - Message to display on error.

View Source
var Lte = base.Assertion{
	DefaultMessage: func(args []core.Value) string {
		return fmt.Sprintf("be %s %s", base.LessOrEqualOp, base.FormatValue(args[1]))
	},
	MinArgs: 2,
	MaxArgs: 3,
	Fn: func(_ context.Context, args []core.Value) (bool, error) {
		return base.LessOrEqualOp.Compare(args)
	},
}

LTE asserts that an actual value is lesser than or equal to an expected one. @param {Any} actual - Actual value. @param {Any} expected - Expected value. @param {String} [message] - Message to display on error.

View Source
var Match = base.Assertion{
	DefaultMessage: func(_ []core.Value) string {
		return "match regular expression"
	},
	MinArgs: 2,
	MaxArgs: 3,
	Fn: func(ctx context.Context, args []core.Value) (bool, error) {
		value := args[0]
		regexp := args[1]

		out, err := strings.RegexMatch(ctx, value, regexp)

		if err != nil {
			return false, err
		}

		return out.Compare(values.True) == 0, nil
	},
}

MATCH asserts that value matches the regular expression. @param {Any} actual - Actual value. @param {String} expression - Regular expression. @param {String} [message] - Message to display on error.

View Source
var None = base.Assertion{
	DefaultMessage: func(_ []core.Value) string {
		return fmt.Sprintf("be %s", base.FormatValue(values.None))
	},
	MinArgs: 1,
	MaxArgs: 2,
	Fn: func(_ context.Context, args []core.Value) (bool, error) {
		return args[0] == values.None, nil
	},
}

NONE asserts that value is none. @param {Any} actual - Value to test. @param {String} [message] - Message to display on error.

View Source
var Object = base.Assertion{
	DefaultMessage: func(_ []core.Value) string {
		return "be object"
	},
	MinArgs: 1,
	MaxArgs: 2,
	Fn: func(_ context.Context, args []core.Value) (bool, error) {
		return args[0].Type() == types.Object, nil
	},
}

OBJECT asserts that value is a object type. @param {Any} actual - Value to test. @param {String} [message] - Message to display on error.

View Source
var String = base.Assertion{
	DefaultMessage: func(_ []core.Value) string {
		return "be string"
	},
	MinArgs: 1,
	MaxArgs: 2,
	Fn: func(_ context.Context, args []core.Value) (bool, error) {
		return args[0].Type() == types.String, nil
	},
}

STRING asserts that value is a string type. @param {Any} actual - Value to test. @param {String} [message] - Message to display on error.

View Source
var True = base.Assertion{
	DefaultMessage: func(_ []core.Value) string {
		return fmt.Sprintf("be %s", base.FormatValue(values.True))
	},
	MinArgs: 1,
	MaxArgs: 2,
	Fn: func(_ context.Context, args []core.Value) (bool, error) {
		return args[0] == values.True, nil
	},
}

TRUE asserts that value is true. @param {Any} actual - Value to test. @param {String} [message] - Message to display on error.

Functions

func RegisterLib

func RegisterLib(ns core.Namespace) error

@namespace T

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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