Documentation
¶
Index ¶
- Constants
- func DefaultIgnoreMismatch(control, candidate []interface{}) bool
- func DefaultMismatchCompare(control, candidate []interface{}) bool
- type Experiment
- func (ex *Experiment) AddCandidate(f interface{})
- func (ex *Experiment) Run(inputs ...interface{}) []interface{}
- func (ex *Experiment) SetCompare(f func([]interface{}, []interface{}) bool)
- func (ex *Experiment) SetControl(f interface{})
- func (ex *Experiment) SetIgnore(f func([]interface{}, []interface{}) bool)
- type Observation
Constants ¶
const VERSION = "0.2"
Variables ¶
This section is empty.
Functions ¶
func DefaultIgnoreMismatch ¶
func DefaultIgnoreMismatch(control, candidate []interface{}) bool
The default ignore mismatch check. It always returns false, so it will never ignore any output mismatches.
func DefaultMismatchCompare ¶
func DefaultMismatchCompare(control, candidate []interface{}) bool
The default output mismatch comparison. If there's a mismatch it will return true.
It loops over all outputs for a candidate and do a simple == comparison against the control's output. It also ensures that the number of outputs of the candidate is the same as the control's.
Types ¶
type Experiment ¶
type Experiment struct {
Name string
Control *Observation
Candidates []*Observation
RunOrder []string
Inputs []interface{}
// contains filtered or unexported fields
}
func NewExperiment ¶
func NewExperiment(name string) *Experiment
Create a new experiment to run and set a name for it.
func (*Experiment) AddCandidate ¶
func (ex *Experiment) AddCandidate(f interface{})
Add a candidate function f. You can add as many as you like.
func (*Experiment) Run ¶
func (ex *Experiment) Run(inputs ...interface{}) []interface{}
Run the experiment, calling the control and candidate functions, one at a time, in a random order. You can optionally provide input arguments to give to the control/candidates.
func (*Experiment) SetCompare ¶
func (ex *Experiment) SetCompare(f func([]interface{}, []interface{}) bool)
Set a custom comparison function. It is run once for each candidate.
Format of the custom comparison function: `func name_of_func(control []interface{}, candidate []interface{}) bool{}` and it should return wether the control outputs "control" is equal to the candidate outputs "candidate".
func (*Experiment) SetControl ¶
func (ex *Experiment) SetControl(f interface{})
Set a function f as the control for the experiemnt. There can only be one control for each experiment and it's required to be set before the experiment can be run.
func (*Experiment) SetIgnore ¶
func (ex *Experiment) SetIgnore(f func([]interface{}, []interface{}) bool)
Set a custom check for if a mismatch, between the control's outputs and a candidate's, should be ignored. It's run once for each candidate with mismatched outputs. A panic for a candidate is always considered a mismatch.
Format of the custom ignore function: `func name_of_func(control []interface{}, candidate []interface{}) bool{}` and it should return wether the output mismatch should be ignored.