Group generator results into array
'cConcat'
combinator function concatenates the results
of generators executed in sequence into one array.
'cJoin' combinator function joins the results of generators
executed in sequence into one string.
Use 'chain' to execute generators in sequence.
object[] circulate(
object gen,
object base,
int count,
object state,
function result_transformer)
Same as 'permutate', 'circulate' executes the argument
generator 'gen' on the default object 'base'
and returns the resulting object array.
In difference to 'permutate', the results of all
attribute generators are combined together.
'current' provides access to current generated object.
'gen' creates a generator that returns the argument value 'v'
when executed on any input object.
Lazy generator evaluation wrapper
used for example by random generators.
'mapGen' is a helper function that
converts all elements of an array to
generators.
'mutate' executes generators 'gs' on the input object o.
'mutateOnAttribute' executes generators 'gs' on an object property
of name 'name'.
object[] permutate(
object gen,
object base,
int count,
object state,
function result_transformer)
'permutate' is one of two supported JSON object
generation functions.
'property' applies generator 'g' on an object property of name
'name' and returns the resulting object.
Creates a linear congruential random generator object using an optional
'seed' value.
any[] repeat(
integer n,
any v)
Repeats value 'v' 'n'-times and returns the resulting array.
'replicate' executes generator 'g' 'n'-times and combines
the results using
combinator function 'f'.
'seq' executes the generators 'gs' and combines the result using
combinator function 'f'.
'setVar' stores the result of one generator that can be used
as input to another generator in same generation process.
Wrappes a value into generator array,
the default input for 'mutate'.
Executes generators 'gs' on an input object
and returns the updated object.
Creates a generator that returns the value of the
variable 'name' when executed.
'withState' provides access to the state object.
'withVar' provides access to variables stored using
setVar
generator.
Parameters:
g
- the generator to wrap
Defined in Popcorn.Core
any cConcat(any r, any n)
Parameters:
r
- combined result of previous executions.
n
- result of current generator evaluation.
Defined in Popcorn.Core
any cJoin(any r, any n)
Parameters:
r
- combined result of previous executions.
n
- result of current generator evaluation.
Defined in Popcorn.Core
Parameters:
f
- a function that takes the result of the generator
'g' and returns a new generator as result.
f
- a function that takes the array result
of all generators 'gs' and returns a new generator as result.
Returns:
the 'chain' generator.
Defined in Popcorn.Core
object[] circulate(object gen, object base, int count, object state, function result_transformer)
Parameters:
gen
- the generator object.
base
- the base test case object.
count
- an optional result count
state
- an optional state object that
can be read and manipulated by any generator.
result_transformer
- an optional function
which takes the result generator object { result:r, state:s }
as argument and returns the desired result. If not defined,
the default transformer returns just the result array.
To return the result and state use 'id' function.
Defined in Popcorn.Core
Parameters:
f
- a callback function that takes the current
generated objects as parameter and returns
this attribute value.
Defined in Popcorn.Core
Parameters:
inp
- any variable, object etc.
Returns:
a
generator which executed returns the value 'v'.
Defined in Popcorn.Core
any id(any value)
Defined in Popcorn.Core
Defined in Popcorn.Core
Defined in Popcorn.Core
Defined in Popcorn.Core
Parameters:
name
- object property name.
Defined in Popcorn.Core
object[] permutate(object gen, object base, int count, object state, function result_transformer)
Parameters:
gen
- the generator object.
base
- the base test case object.
count
- an optional result count
state
- an optional state object that
can be read and manipulated by any generator.
result_transformer
- an optional function
which takes the result generator object { result:r, state:s }
as argument and returns the desired result. If not defined,
the default transformer returns just the result array.
To return the result and state use 'id' function.
Defined in Popcorn.Core
Parameters:
name
- object property name.
Defined in Popcorn.Core
Returns:
the random generator object.
Defined in Popcorn.Core
any[] repeat(integer n, any v)
Parameters:
n
- repeat count.
v
- object or generator to repeat.
Defined in Popcorn.Core
Parameters:
init
- the initial value for the
combinator function 'f'.
Returns:
the replicator generator
Defined in Popcorn.Core
Parameters:
init
- the initial value passed on first call to the
combinator.
Returns:
the sequence generator that evaluates the generators 'gs' when executed.
Defined in Popcorn.Core
Parameters:
name
- variable name the generator value is stored for.
g
- the generator to execute.
Returns:
result of the generator 'g'.
Defined in Popcorn.Core
Defined in Popcorn.Core
Defined in Popcorn.Core
Defined in Popcorn.Core
Parameters:
f
- takes the state object as argument and
returns a new generator as result.
Defined in Popcorn.Core
Parameters:
name
- variable name.
f
- takes the variable as argument and returns
a new generator as result.
Defined in Popcorn.Core
The generator library is build on top of the monadic combinators 'return' and 'bind' called 'gen' and 'chain'. However for better performance most internal generators have imperative implementations.