Skip to content

add Dict fuzzers: dict, dict_between, dict_at_least, dict_at_most, dict_from - #25

Open
MavenRain wants to merge 1 commit into
aiken-lang:mainfrom
MavenRain:dict-fuzzers
Open

add Dict fuzzers: dict, dict_between, dict_at_least, dict_at_most, dict_from#25
MavenRain wants to merge 1 commit into
aiken-lang:mainfrom
MavenRain:dict-fuzzers

Conversation

@MavenRain

Copy link
Copy Markdown

Closes #24 (the aiken/fuzz/dict bullets from #2).

Adds Dict fuzzers to aiken/fuzz, next to the set family:

  • dict(fuzz_key, fuzz_value): up to 20 elements
  • dict_between(fuzz_key, fuzz_value, min, max)
  • dict_at_least(fuzz_key, fuzz_value, min)
  • dict_at_most(fuzz_key, fuzz_value, max)
  • dict_from(fuzz_keys, fuzz_value): one value per sampled key

Design notes:

  • Keys come from set_between, so they are unique and the size distribution is the documented set_between one. Values are generated one per key and inserted with dict.insert.
  • The key fuzzer is Fuzzer<ByteArray> rather than the Fuzzer<k> written in TODOs #2: Dict stores keys as ByteArray internally and dict.insert takes key: ByteArray. The phantom key type parameter is left free for the caller to pin.
  • dict_from collapses duplicate keys (last generated value wins), so the result can be smaller than the sample.
  • Placement follows Added rational number fuzzer functions and corresponding tests #19 (rational fuzzers): directly in aiken/fuzz, not a submodule, which also avoids a name clash between a fuzz/dict module and the stdlib dict module.

Testing: 7 new property tests in lib/aiken/fuzz.test.ak covering size bounds for all four size variants, key uniqueness and strict key ordering, value ranges, and duplicate collapse in dict_from. Full suite: 48/48 green under the pinned compiler (v1.1.17); formatter check (fmt --check) clean under v1.1.17.

…_most' and 'dict_from'.

Covers the 'aiken/fuzz/dict' bullet points from the TODO list (aiken-lang#2).

Keys are generated with 'set_between' (so they are unique), then one
value is generated per key and inserted with 'dict.insert'. The key
fuzzer is 'Fuzzer<ByteArray>' because 'Dict' keys are 'ByteArray'
under the hood; the phantom 'key' type parameter is left free for the
caller to pin.

Signed-off-by: Onyeka Obi <softwareengineerasaservant@isurvivable.cv>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Dict fuzzers (aiken/fuzz/dict bullets of the TODO list)

1 participant