Skip to content

Add Fuzz.set and Fuzz.dict #236

@jfmengels

Description

@jfmengels

The Fuzz module has Fuzz.list and Fuzz.array, but doesn't have Fuzz.set nor Fuzz.dict.

Currently, these are relatively easy to create in user code, but having to do this every time we need such a fuzzer is tedious.

I haven't tried them out but I believe these implementations would work (or be good starting positions if they don't).

set : Fuzz comparable -> Fuzz (Set comparable)
set fuzzer =
  list fuzzer
    |> map Set.fromList

dict : Fuzz comparable -> Fuzz a -> Fuzz (Dict comparable a)
dict keyFuzzer valueFuzzer =
  list (Tuple.pair keyFuzzer valueFuzzer)
    |> map Dict.fromList

There is a risk of generating the same keys multiple times which is wasteful, and maybe there are better implementations. In the meantime, I think this would be a valuable addition to the package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions