]> git.rkrishnan.org Git - functorrent.git/commitdiff
QuickCheck tests now terminate successfully.
authorRamakrishnan Muthukrishnan <ram@rkrishnan.org>
Sun, 26 Apr 2015 12:09:01 +0000 (17:39 +0530)
committerRamakrishnan Muthukrishnan <ram@rkrishnan.org>
Sun, 26 Apr 2015 12:09:01 +0000 (17:39 +0530)
The trick is to reduce the amount of data we generate for recursive
types. The hint is in the QuickCheck manual.

src/FuncTorrent/Bencode.hs

index 8b6ff5229909266a42e85bb4a47952f32afe7af8..62d476733530ad650d6a293f5255d3c6c26ba147 100644 (file)
@@ -38,9 +38,9 @@ instance Arbitrary BVal where
                                , Bstr <$> arbitrary]
                 bval n = oneof [ Bint <$> arbitrary
                                , Bstr <$> arbitrary
-                               , Blist <$> vectorOf n arbitrary
+                               , Blist <$> vectorOf n (bval (n `div` 4))
                                , do keys <- vectorOf n arbitrary
-                                    vals <- vectorOf n arbitrary
+                                    vals <- vectorOf n (bval (n `div` 4))
                                     return $ Bdict $ fromList $ zip keys vals ]
 
 -- getters