[Haskell-cafe] Quickcheck: Help on non trivial test
arnaud.oqube at gmail.com
Thu Jun 23 11:18:38 CEST 2011
What if the '2' that appears in splitPos is itself generated (ie. an int
parameter of splitFunGen) and you replace `div` by `mod`? Sorry, I have no
code to show right now.
On Thu, Jun 23, 2011 at 10:58 AM, jean-christophe mincke <
jeanchristophe.mincke at gmail.com> wrote:
> Hello Café,
> I am using quicheck for some kind of non trivial tests.
> The general form of these tesst is summarized by the following code.
> -- Function to be tested. Given a list of splitting functions, split the
> given list
> process :: [a] -> [[a] -> [a]] -> [a]
> process l splitFuns =
> List.foldl proc l splitFuns
> proc l splitFun = splitFun l
> -- a split function generator
> splitFunGen :: Gen ([a] -> [a])
> splitFunGen = return $ proc
> proc l = let splitPos = List.length l `div` 2 --
> Problem I would like splitPos = some random value between [0 and length of
> in fst $ List.splitAt splitPos l
> splitFunsGen :: Gen [[a] -> [a]]
> splitFunsGen = vectorOf 20 splitFunGen
> instance Show a => Show ([a] -> [a]) where
> show _ = " a split fun "
> r = quickCheck $ forAll splitFunsGen prop
> prop splitFuns = let l = process [1..100] splitFuns
> in List.length l >= 0 -- dummy test here for
> the sake of example
> The process to be tested takes a list that is randomly perturbated
> (spitFuns). The result of each perturbation is fed into the next
> Ideally I would like the perturbating function to depend on the previous
> perturbated list (see computation of splitPos in splitFunGen).
> I am not sure how I could use quickcheck in this case.
> Has anyone a better idea?
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe