Created
August 4, 2017 12:36
-
-
Save gampleman/a003ef24ba4d1a131cf86e13112bf581 to your computer and use it in GitHub Desktop.
Function Fuzzers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module FunctionFuzzers exposing (..) | |
import Fuzz exposing (Fuzzer) | |
import Test.Runner exposing (fuzz) | |
import Shrink | |
import Random.Pcg as Random | |
import Murmur3 | |
function : Fuzzer a -> Fuzzer (b -> a) | |
function retType = | |
let | |
gen = | |
fuzz retType | |
fn initialSeed a = | |
a | |
|> toString | |
|> Murmur3.hashString initialSeed | |
|> Random.initialSeed | |
|> Random.step gen | |
|> Tuple.first | |
|> Tuple.first | |
generator = | |
Random.int Random.minInt Random.maxInt | |
|> Random.map fn | |
shrinker = | |
Shrink.noShrink | |
in | |
Fuzz.custom generator shrinker | |
function2 : Fuzzer c -> Fuzzer (a -> b -> c) | |
function2 = | |
Fuzz.map curry << function | |
function3 : Fuzzer d -> Fuzzer (a -> b -> c -> d) | |
function3 = | |
Fuzz.map (curry >> curry) << function | |
function4 : Fuzzer e -> Fuzzer (a -> b -> c -> d -> e) | |
function4 = | |
Fuzz.map (curry >> curry >> curry) << function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment