ExopData v0.1.7 ExopData.CommonGenerators View Source
Functions to create and combine generators.
Link to this section Summary
Link to this section Functions
Link to this function
atom(options \\ [])
View Source
atom(options \\ [])
View Source
atom(keyword()) :: StreamData.t()
atom(keyword()) :: StreamData.t()
Generates atoms.
Options
:length
- (integer or range) if an integer, the exact length the generated atoms should be; if a range, the range in which the length of the generated atoms should be. If provided,:min_length
and:max_length
are ignored.:min_length
- (integer) the minimum length of the generated atoms.:max_length
- (integer) the maximum length of the generated atoms.
Examples
Enum.take(ExopData.CommonGenerators.atom(), 3)
#=> [:xF, :y, :B_]
Link to this function
map(data_map, optional_keys)
View Source
map(data_map, optional_keys)
View Source
map([StreamData.t()], [atom()]) :: StreamData.t()
map([StreamData.t()], [atom()]) :: StreamData.t()
Allow to generate maps with optional keys and generated values.
data_map
is a map of fixed_key => data
pairs.
optional_keys
is a list of optional keys, which can be or cannot be in final result.
Examples
data = ExopData.CommonGenerators.map(
%{
integer: StreamData.integer(),
binary: StreamData.binary(),
},
[:integer]
)
Enum.take(data, 3)
#=> [%{binary: "a", integer: 1}, %{binary: "b"}, %{binary: "c", integer: 2}]