Hello Café,<br><br>I am using quicheck for some kind of non trivial tests.<br><br>The general form of these tesst is summarized by the following code.<br><br><br>
-- Function to be tested. Given a list of splitting functions, split the given list<br>
process :: [a] -> [[a] -> [a]] -> [a] <br>
process l splitFuns = <br>
List.foldl proc l splitFuns<br>
where<br>
proc l splitFun = splitFun l<br>
<br>
-- a split function generator <br>
splitFunGen :: Gen ([a] -> [a])<br>
splitFunGen = return $ proc<br>
where <br>
proc l = let splitPos = List.length l `div` 2 --
Problem I would like splitPos = some random value between [0 and length
of l] <br>
in fst $ List.splitAt splitPos l<br>
<br>
splitFunsGen :: Gen [[a] -> [a]]<br>
splitFunsGen = vectorOf 20 splitFunGen<br>
<br>
instance Show a => Show ([a] -> [a]) where <br>
show _ = " a split fun "<br>
<br>
r = quickCheck $ forAll splitFunsGen prop <br>
where<br>
prop splitFuns = let l = process [1..100] splitFuns<br>
in List.length l >= 0 -- dummy test here for the sake of example<br><br><br>The process to be tested takes a list that is randomly perturbated (spitFuns). The result of each perturbation is fed into the next perturbation.<br>
<br>Ideally I would like the perturbating function to depend on the previous perturbated list (see computation of splitPos in splitFunGen).<br><br>I am not sure how I could use quickcheck in this case. <br><br>Has anyone a better idea?<br>
<br>Thanks<br><br>J-C<br> <br>