leanovate / gopter

GOlang Property TestER
MIT License
599 stars 40 forks source link

Ensure that gen.Struct is reproducible for a given seed #45

Closed au-phiware closed 6 years ago

au-phiware commented 6 years ago

Prior to this change, gen.Struct produced a value by ranging over items in a map, which in turn draws values from the gopter.Gens from the items, which in turn presumedly makes calls to the PRNG in the gopter.GenParameters. Ranging over items in a map is intentionally non-deterministic, therefore the calls to the PRNG is also non-deterministic.

This change extracts the keys from the map, sorts them and then ranges over the keys. This ensures that the calls to PRNG is deterministic.

fixes #44

untoldwind commented 6 years ago

Looks good