summaryrefslogtreecommitdiff
path: root/test.hs
diff options
context:
space:
mode:
Diffstat (limited to 'test.hs')
-rw-r--r--test.hs33
1 files changed, 33 insertions, 0 deletions
diff --git a/test.hs b/test.hs
new file mode 100644
index 0000000..a8780ff
--- /dev/null
+++ b/test.hs
@@ -0,0 +1,33 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE QuasiQuotes #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+
+module Main where
+
+import qualified Data.ByteString.Char8 as B
+import Data.FastQ
+import Data.Function
+import qualified Streamly.Data.Fold as F
+import qualified Streamly.Data.Stream as S
+import qualified Streamly.Data.Unfold as U
+import Test.QuickCheck
+import Test.QuickCheck.Arbitrary
+import Test.QuickCheck.Monadic
+import Prelude hiding (Read)
+
+instance Arbitrary Read where
+ arbitrary = Read <$> genStr <*> genStr <*> genStr
+ where
+ genBS = fmap B.pack . listOf . elements
+ genStr = genBS $ [' ' .. '*'] ++ [',' .. '?'] ++ ['A' .. '~']
+
+main :: IO ()
+main = quickCheckWith stdArgs {maxSuccess = 10000} $ \rp -> monadicIO $ do
+ rp' <- run $ do
+ S.unfold U.fromList rp & unparse "a" "b"
+ cnt <- B.readFile "a"
+ B.writeFile "a" $ cnt <> cnt
+ cnt <- B.readFile "b"
+ B.writeFile "b" $ cnt <> cnt
+ parse "a" "b" & S.fold F.toList
+ assert $ rp <> rp == rp'