You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the existing data generators (functions under the Pollution.VG module such as int, float, etc), it is possible to specify options such as min, max and must_have values. However, it is not possible to filter out generated values.
Proposal
Add the possibility to use the existing filters option that is not taken into account when passed to the Pollution.VG.int function, among others.
The previous filter specification causes the generator to discard odd integers.
It would be nice if we could use the filter option with all the VG functions.
Details
In my understanding, functions under the Pollution.VG module generates a State struct that acts as a specification that Pollution.Generator uses to generate random values.
Looking inside the following summarized State returned by the following call Pollution.VG.int:
%Pollution.State{
......,
filters: %{}, .....}
We can see that some filter facility is already defined, but seems to be disabled.
In the lib/pollution/generator.ex file, we can see under the as_stream function that filters are fetched and applied to the resulting Stream.
Is there any non obvious concerns regarding filters: that should be addressed before implementing them?
Use case
I came across the need to generate positive integers that are powers of two (1, 2, 4, 8, 16, 32 ...) in my property based tests, the filters: option can help in achieving this behavior.
Kind Regards.
The text was updated successfully, but these errors were encountered:
MissaouiChedy
changed the title
Resources and guidelines for creating custom generators
Add the filters option to the int(), float() and wherever applicable
Jun 9, 2017
MissaouiChedy
changed the title
Add the filters option to the int(), float() and wherever applicable
Add the filters option to int(), float() and to the rest of the VG functions
Jun 9, 2017
Pain point
When using the existing data generators (functions under the
Pollution.VG
module such asint
,float
, etc), it is possible to specify options such asmin
,max
andmust_have
values. However, it is not possible to filter out generated values.Proposal
Add the possibility to use the existing
filters
option that is not taken into account when passed to thePollution.VG.int
function, among others.Here is an example usage:
The previous filter specification causes the generator to discard odd integers.
It would be nice if we could use the filter option with all the
VG
functions.Details
In my understanding, functions under the
Pollution.VG
module generates aState
struct that acts as a specification thatPollution.Generator
uses to generate random values.Looking inside the following summarized
State
returned by the following callPollution.VG.int
:We can see that some filter facility is already defined, but seems to be disabled.
In the
lib/pollution/generator.ex
file, we can see under theas_stream
function that filters are fetched and applied to the resultingStream
.However in the
Pollution.Generator.Int.create
function, thefilters:
option is ignored when creating theState
struct.Questions
filters:
ignored?filters:
that should be addressed before implementing them?Use case
I came across the need to generate positive integers that are powers of two (
1, 2, 4, 8, 16, 32 ...
) in my property based tests, thefilters:
option can help in achieving this behavior.Kind Regards.
The text was updated successfully, but these errors were encountered: