on master help sign in
Enable splitOnSeq tests

These tests were already written but commented out.

commitea40591785b0168614069e2bc37bf2a82ba279dd authorHarendra Kumar <harendra@composewell.com> dateThu 29 Oct 2020, 04:10 (6 years ago) parent7e3f44d
1 file changed+16−12
test/Streamly/Test/Prelude/Serial.hs+16−12
test/Streamly/Test/Prelude/Serial.hs+16−12
@@ -29,6 +29,8 @@ import Test.QuickCheck
2929 , forAll
3030 , frequency
3131 , listOf
32+ , listOf1
33+ , suchThat
3234 , vectorOf
3335 , withMaxSuccess
3436 )
@@ -110,45 +112,49 @@ groupSplitOps desc = do
110112 splitOnSeq
111113 splitOnSuffixSeq
112114 -- XXX add tests with multichar separators too
113−{-
115+
116+ let split xs ys =
117+ S.toList $ IS.splitOnSeq (A.fromList ys) FL.toList (S.fromList xs)
114118 prop (desc <> " intercalate . splitOnSeq == id (nil separator)") $
115119 forAll listWithZeroes $ \xs -> do
116120 withMaxSuccess maxTestCount $
117121 monadicIO $ do
118− ys <- S.toList $ FL.splitOnSeq [] toListFL (S.fromList xs)
122+ ys <- split xs []
119123 listEquals (==) (intercalate [] ys) xs
120124
121125 prop (desc <> " intercalate . splitOnSeq == id (single element separator)") $
122126 forAll listWithZeroes $ \xs -> do
123127 withMaxSuccess maxTestCount $
124128 monadicIO $ do
125− ys <- S.toList $ FL.splitOnSeq [0] toListFL (S.fromList xs)
129+ ys <- split xs [0]
126130 listEquals (==) (intercalate [0] ys) xs
127131
128− prop (desc <> " concat . splitOnSeq . intercalate == concat (nil separator/possibly empty list)") $
132+ prop (desc <> " concat . splitOnSeq . intercalate == concat "
133+ <> "(nil separator/possibly empty list)") $
129134 forAll listsWithoutZeroes $ \xss -> do
130135 withMaxSuccess maxTestCount $
131136 monadicIO $ do
132137 let xs = intercalate [] xss
133− ys <- S.toList $ FL.splitOnSeq [0] toListFL (S.fromList xs)
138+ ys <- split xs [0]
134139 listEquals (==) (concat ys) (concat xss)
135140
136− prop (desc <> " concat . splitOnSeq . intercalate == concat (non-nil separator/possibly empty list)") $
141+ prop (desc <> " concat . splitOnSeq . intercalate == "
142+ <> "concat (non-nil separator/possibly empty list)") $
137143 forAll listsWithoutZeroes $ \xss -> do
138144 withMaxSuccess maxTestCount $
139145 monadicIO $ do
140146 let xs = intercalate [0] xss
141− ys <- S.toList $ FL.splitOnSeq [0] toListFL (S.fromList xs)
147+ ys <- split xs [0]
142148 listEquals (==) (concat ys) (concat xss)
143149
144− prop (desc <> " splitOnSeq . intercalate == id (exclusive separator/non-empty list)") $
150+ prop (desc <> " splitOnSeq . intercalate == id "
151+ <> "(exclusive separator/non-empty list)") $
145152 forAll listsWithoutZeroes1 $ \xss -> do
146153 withMaxSuccess maxTestCount $
147154 monadicIO $ do
148155 let xs = intercalate [0] xss
149− ys <- S.toList $ FL.splitOnSeq [0] toListFL (S.fromList xs)
156+ ys <- split xs [0]
150157 listEquals (==) ys xss
151−-}
152158
153159 prop (desc <> " intercalate [x] . splitOn (== x) == id") $
154160 forAll listWithZeroes $ \xs -> do
@@ -162,7 +168,6 @@ groupSplitOps desc = do
162168 listWithZeroes :: Gen [Int]
163169 listWithZeroes = listOf $ frequency [(3, arbitrary), (1, elements [0])]
164170
165−{-
166171 listWithoutZeroes = vectorOf 4 $ suchThat arbitrary (/= 0)
167172
168173 listsWithoutZeroes :: Gen [[Int]]
@@ -170,7 +175,6 @@ groupSplitOps desc = do
170175
171176 listsWithoutZeroes1 :: Gen [[Int]]
172177 listsWithoutZeroes1 = listOf1 listWithoutZeroes
173−-}
174178
175179-- |
176180-- After grouping (and folding) Int stream using @>@ operation,