Add my (old) testsuite
[darcs-mirrors/vector.git] / testsuite / Testsuite / Utils / Generator.hs
1 module Testsuite.Utils.Generator (
2 indices, index_value_pairs
3 ) where
4
5 import Test.QuickCheck
6
7 indices :: Int -> Gen [Int]
8 indices 0 = return []
9 indices m = sized $ \n ->
10 do
11 len <- choose (0,n)
12 sequence [choose (0,m-1) | i <- [1..len]]
13
14 index_value_pairs :: Arbitrary a => Int -> Gen [(Int,a)]
15 index_value_pairs 0 = return []
16 index_value_pairs m = sized $ \n ->
17 do
18 len <- choose (0,n)
19 is <- sequence [choose (0,m-1) | i <- [1..len]]
20 xs <- vector len
21 return $ zip is xs
22