states

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: AGPL-3.0 Imports: 1 Imported by: 1

Documentation

Overview

Package states supports writing more complex state machine tests with the rapid property test framework.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PerformOne

func PerformOne(t *rapid.T, actions ...Action)

PerformOne chooses one property test action from a list and performs it. Actions are able to provide a precondition that must be satisfied; if it is not, the action is not included in the list of potential actions.

Types

type Action

type Action interface {
	// IsEnabled returns whether this action's precondition holds.  If not, it
	// will not be included in the list of potential actions.
	IsEnabled() bool

	// Perform performs the action.
	Perform()
}

Action is a potential action that can be performed by PerformOne.

var DisabledAction Action = disabledAction{}

DisabledAction is an Action whose precondition never holds, and can therefore never be selected.

type ActionFunc

type ActionFunc func()

ActionFunc lets you use a simple function as an Action in PerformOne. Its precondition always holds.

func (ActionFunc) IsEnabled

func (f ActionFunc) IsEnabled() bool

func (ActionFunc) Perform

func (f ActionFunc) Perform()

type Test

type Test struct {
	// contains filtered or unexported fields
}

Test provides an Action that can be used to stop a test. It's useful in test cases where you need to perform an arbitrarily long sequence of actions.

func (*Test) Finish

func (ct *Test) Finish() Action

FinishTest is an Action that, if selected, causes the test to finish.

func (*Test) PerformOne

func (ct *Test) PerformOne(t *rapid.T, actions ...Action)

PerformOne randomly decides to either finish the test, or to perform a random action.

func (*Test) ShouldContinue

func (ct *Test) ShouldContinue() bool

ShouldContinue returns whether we should continue with the test.

Jump to

Keyboard shortcuts

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