Documentation ¶
Overview ¶
Package predicate defines both `Predicate“ and `Transform` types and handles the predicate evaluation process.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatContextValues ¶
func FormatContextValues(values []ContextValue) string
FormatContextValues returns a string containing the formated print-out of the context values.
Types ¶
type ContextValue ¶
ContextValue capture one original, intermediate or final value generated during the evaluation of a predicate. Each value has a `Name`, a `Value`, and a `Pre` flag indicating if the value is a preformatted string that should be printed as is, or an actual value that should be printed with adequate formatting.
type Predicate ¶
type Predicate struct { Transformations []Transformation Description string Func PredicateFunc }
Predicate captures a complete predicate chain with `Transformations`, a `Description` and an actual evaluation function `Func`.
func (*Predicate) Evaluate ¶
func (p *Predicate) Evaluate(value interface{}) (success bool, context []ContextValue)
Evaluate evaluates the full predicate chain on the given `value`, and returns a `success` flag and, upon failure, a `context` containing all the relevant values captured during evaluation.
func (*Predicate) FormatDescription ¶
FormatDescription return a formatted description of the full predicate chain, using the `value` string to represent the input value.
func (*Predicate) RegisterPredicate ¶
func (p *Predicate) RegisterPredicate(desc string, f PredicateFunc)
RegisterPredicate sets the predicate evaluation function and description for the current predicate.
func (*Predicate) RegisterTransformation ¶
func (p *Predicate) RegisterTransformation(desc string, f TransformFunc)
RegisterTransformation appends the given transformation to the list of transformations attached to the predicate.
type PredicateFunc ¶
type PredicateFunc func( value interface{}) ( success bool, ctx []ContextValue, err error)
PredicateFunc is the function type for use in a `Predicate`.
type T ¶
type T interface { Helper() Errorf(format string, args ...interface{}) FailNow() Cleanup(f func()) }
T is a minimal abstracted interface of testing.T for the purpose of // predicate construction and evaluation.
type TransformFunc ¶
type TransformFunc func( value interface{}) ( result interface{}, ctx []ContextValue, err error)
TransformFunc is the function type for use in a `Transformation`.
type Transformation ¶
type Transformation struct { Description string Func TransformFunc }
Transformation captures one transformation step in the predicate evaluation chain, with a `Description` and an actual transformation function `Func`.
Directories ¶
Path | Synopsis |
---|---|
Package impl defines all the support predicates and transformation function as individual functions that are then forwarded through code generation to the Builder type.
|
Package impl defines all the support predicates and transformation function as individual functions that are then forwarded through code generation to the Builder type. |