gopter.GenParameters
now has aCloneWithSeed(seed int64)
function to temparary copies to create rerunable sections of code.- Added
gopter.Gen.MapResult
for power-user mappings - Added
gopter.DeriveGen
to derive a generator and it's shrinker from a bi-directional mapping (gopter.BiMapper
)
-
Refactored
commands
package under the hood to allow the use of mutable state. Re-runability of commands is provided by invoking thecommands.GenInitialState
generator with the samegopter.GenParameters
. Of coursecommands.GenInitialState
is supposed to create the same state for the same parameters every time. -
Fixed a bug in
commands
that might lead to shrinked command sequences not satisfying the precondtions. -
commands.Command.PostCondition
was called with the state before running the command. It makes much more sense to first docommands.Command.NextState
and thencommands.Command.PostCondition
-
commands.Commands.NewSystemUnderTest
now takes has an argumentinitialState commands.State
to allow implementators to create/bootstrap a system under test based on an arbitrary initial state. So far examples were just using a constant initial state ... which is a bit boring. -
Fixed: Actually use
commands.Commands.InitialPreCondition
as sieve forcommands.Commands.GenInitialState
-
Gen.Map and Shrink.Map now accept
interface{}
instead offunc (interface{}) interface{}
This allows cleaner mapping functions without type conversion. E.g. instead of
gen.AnyString().Map(function (v interface{}) interface{} { return strings.ToUpper(v.(string)) })
you can (and should) now write
gen.AnyString().Map(function (v string) string { return strings.ToUpper(v) })
-
Correspondingly Gen.SuchThat now also ccept
interface{}
instead offunc (interface{}) bool
This allows cleaner sieve functions without type conversion. E.g. instead of
gen.AnyString().SuchThat(function (v interface{}) bool { return HasPrefix(v.(string), "P") })
you can (and should) now write
gen.AnyString().SuchThat(function (v string) bool { return HasPrefix(v, "P") })
-
Gen.FlatMap now has a second parameter
resultType reflect.Type
defining the result type of the mapped generator -
Reason for these changes: The original
Map
andFlatMap
had a recurring issue with empty results. If the original generator created an empty result there was no clean way to determine the result type of the mapped generator. The new version fixes this by extracting the return type of the mapping functions.
0.1 - 2016-04-30
- Initial implementation.