elm-explorations / elm-explorations/test
Fuzzers for functions
- Dominant language
- Elm
- Stars
- 244
- Forks
- 40
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 2
Description
The idea, as far as I understand it, is to generate a list of mappings from `a` to `b`, and convert that list to a function.
There are a bunch of functions to change these: map works as usual, to change the `b` into `c`, but we can also have `coMap` (profunctor?) that works on the input instead of on the output: given a `z -> a` function, it changes `a -> b` to `z -> b`.
The simplest generated functions map all values to some default value, and more complicated functions have exceptions from the default (ie. "map 9 to 1, map everything else to 0"). Such functions with exceptions do shrink towards the "no exception" case (a constant function).
Prior art:
* https://www.google.com/search?q=%22Shrinking+and+showing+functions%22+Koen+Claessen
* https://www.youtube.com/watch?v=CH8UQJiv9Q4
* https://hackage.haskell.org/package/QuickCheck-2.14.3/docs/Test-QuickCheck-Function.html
* https://hackage.haskell.org/package/QuickCheck-2.13.1/docs/Test-QuickCheck.html#t:Function
* https://hackage.haskell.org/package/QuickCheck-2.13.1/docs/Test-QuickCheck.html#v:Fun
* https://hackage.haskell.org/package/QuickCheck-2.13.1/docs/Test-QuickCheck-Arbitrary.html#t:CoArbitrary
A classic poster child example of "hey we can generate functions" in the PBT context is testing that `map f (filter p xs) == filter p (map f xs)`. (This is not true.)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.