testing

package
v2.0.0-alpha.5 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

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

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

View Source
var Empty = base.Assertion{
	DefaultMessage: func(_ []runtime.Value) string {
		return "be empty"
	},
	Args: base.Args{
		Min: 1,
		Max: 2,
	},
	Fn: func(ctx context.Context, args []runtime.Value) (bool, error) {
		value := args[0]

		if err := runtime.AssertMeasurable(value); err != nil {
			return false, err
		}

		return runtime.IsEmpty(ctx, value)
	},
}

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

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(_ []runtime.Value) string {
		return "not fail"
	},
	Args: base.Args{
		Min: 0,
		Max: 1,
	},
	Fn: func(ctx context.Context, args []runtime.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(args []runtime.Value) string {
		return fmt.Sprintf("be %s", base.FormatValue(runtime.False))
	},
	Args: base.Args{
		Min: 1,
		Max: 2,
	},
	Fn: func(ctx context.Context, args []runtime.Value) (bool, error) {
		return args[0] == runtime.False, nil
	},
}

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

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

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.

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 []runtime.Value) string {
		return fmt.Sprintf("include %s", base.FormatValue(args[1]))
	},
	Args: base.Args{
		Min: 2,
		Max: 3,
	},
	Fn: func(ctx context.Context, args []runtime.Value) (bool, error) {
		haystack := args[0]
		needle := args[1]

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

		if err != nil {
			return false, err
		}

		return runtime.CompareValues(out, runtime.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.

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 []runtime.Value) string {
		return fmt.Sprintf("has size %s", args[1])
	},
	Args: base.Args{
		Min: 2,
		Max: 3,
	},
	Fn: func(ctx context.Context, args []runtime.Value) (bool, error) {
		col := args[0]
		size := args[1]

		if err := runtime.AssertMeasurable(col); err != nil {
			return false, err
		}

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

		if err != nil {
			return false, err
		}

		return runtime.CompareValues(out, 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.

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.

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(args []runtime.Value) string {
		return "match regular expression"
	},
	Args: base.Args{
		Min: 2,
		Max: 3,
	},
	Fn: func(ctx context.Context, args []runtime.Value) (bool, error) {
		value := args[0]
		regexp := args[1]

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

		if err != nil {
			return false, err
		}

		return runtime.CompareValues(out, runtime.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.

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

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

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

View Source
var True = base.Assertion{
	DefaultMessage: func(args []runtime.Value) string {
		return fmt.Sprintf("be %s", base.FormatValue(runtime.True))
	},
	Args: base.Args{
		Min: 1,
		Max: 2,
	},
	Fn: func(ctx context.Context, args []runtime.Value) (bool, error) {
		return args[0] == runtime.True, nil
	},
}

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

Functions

func RegisterLib

func RegisterLib(ns runtime.Namespace)

@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