mirror of
https://github.com/composewell/streamly.git
synced 2024-08-16 23:10:36 +03:00
Fix serialize test taking too long, too much mem
This commit is contained in:
parent
55cc5d051e
commit
191abebe92
@ -268,6 +268,7 @@ instance NFData a => NFData (BinTree a) where
|
||||
rnf (Leaf a) = rnf a `seq` ()
|
||||
rnf (Tree l r) = rnf l `seq` rnf r
|
||||
|
||||
-- XXX This may not terminate, or could become really large.
|
||||
instance Arbitrary a => Arbitrary (BinTree a) where
|
||||
arbitrary = oneof [Leaf <$> arbitrary, Tree <$> arbitrary <*> arbitrary]
|
||||
|
||||
@ -559,8 +560,6 @@ main = do
|
||||
let !len = length lInt -- evaluate the list
|
||||
#endif
|
||||
#ifndef FUSION_CHECK
|
||||
-- This can take too much memory/CPU, need to restrict the test
|
||||
-- runQC
|
||||
#ifdef USE_UNBOX
|
||||
runWithCLIOpts defaultStreamSize allBenchmarks
|
||||
#else
|
||||
@ -568,7 +567,6 @@ main = do
|
||||
`seq` runWithCLIOpts
|
||||
defaultStreamSize
|
||||
(allBenchmarks tInt lInt recL recR)
|
||||
|
||||
#endif
|
||||
#else
|
||||
-- Enable FUSION_CHECK macro at the beginning of the file
|
||||
|
@ -109,9 +109,19 @@ $(Serialize.deriveSerializeWith
|
||||
CONF
|
||||
[d|instance Serialize a => Serialize (BinTree a)|])
|
||||
|
||||
-- XXX This may not terminate, or could become really large.
|
||||
instance Arbitrary a => Arbitrary (BinTree a) where
|
||||
arbitrary = oneof [Leaf <$> arbitrary, Tree <$> arbitrary <*> arbitrary]
|
||||
|
||||
-- Make a balanced tree of given level
|
||||
mkBinTree :: (Arbitrary a) => Int -> IO (BinTree a)
|
||||
mkBinTree = go (generate arbitrary)
|
||||
|
||||
where
|
||||
|
||||
go r 0 = Leaf <$> r
|
||||
go r n = Tree <$> go r (n - 1) <*> go r (n - 1)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Record syntax type
|
||||
--------------------------------------------------------------------------------
|
||||
@ -207,6 +217,10 @@ roundtrip
|
||||
-> IO ()
|
||||
roundtrip val = do
|
||||
|
||||
-- For debugging large size generated by arbitrary
|
||||
-- let sz = Serialize.addSizeTo 0 val
|
||||
-- putStrLn $ "Size is: " ++ show sz
|
||||
|
||||
val `shouldBe` Array.deserialize (Array.pinnedSerialize val)
|
||||
|
||||
res <- poke val
|
||||
@ -270,7 +284,12 @@ testCases = do
|
||||
$ \(x :: [CustomDatatype]) -> roundtrip x
|
||||
|
||||
limitQC
|
||||
$ prop "BinTree" $ \(x :: BinTree Int) -> roundtrip x
|
||||
$ prop "BinTree"
|
||||
$ forAll (elements [1..15])
|
||||
(\(x :: Int) -> do
|
||||
(r :: BinTree Int) <- mkBinTree x
|
||||
roundtrip r
|
||||
)
|
||||
|
||||
where
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user