haskell - How to generate arbitrary two argument function with QuickCheck? -
i trying test implementation of zipwith
using quickcheck. implementation, myzipwith
, quickcheck test comparing standard function. like:
main = quickcheck (prop_myzipwith :: (int -> int -> int) -> [int] -> [int] -> bool) prop_myzipwith :: (a -> b -> c) -> [a] -> [b] -> bool prop_myzipwith f x y = (myzipwith x y) == (zipwith f x y)
this not work because (int -> int -> int)
not instance of arbitrary
.
with single-argument functions 1 can around using test.quickcheck.function
's fun
(which instantiates arbitrary
). example:
main = quickcheck (prop_mymap :: fun int int -> [int] -> bool) prop_mymap :: fun b -> [a] -> bool prop_mymap (fun _ f) l = (mymap f l) == (map f l)
i trying similar except generating two-argument arbitrary functions.
how can generate arbitrary instances of 2 argument functions quickcheck testing of higher-order functions such zipwith
?
wiki
Comments
Post a Comment