1module Main (main) where
3import Streamly.Test.Common (listEquals, chooseInt)
4import Test.Hspec (hspec, describe)
5import Test.Hspec.QuickCheck
6import Test.QuickCheck (forAll, Property, vectorOf, Gen)
7import Test.QuickCheck.Monadic (monadicIO, run)
9import qualified Streamly.Internal.Data.Array.Foreign as Array
10import qualified Streamly.Internal.Data.Array.Stream.Foreign as ArrayStream
11import qualified Streamly.Internal.Data.Fold as Fold
12import qualified Streamly.Internal.Data.Parser.ParserD as ParserD
13import qualified Streamly.Internal.Data.Stream.IsStream as Stream
14import qualified Test.Hspec as Hspec
16import Prelude hiding (sequence)
18#if MIN_VERSION_QuickCheck(2,14,0)
20import Test.QuickCheck (chooseAny)
24import System.Random (Random(random))
25import Test.QuickCheck.Gen (Gen(MkGen))
27-- | Generates a random element over the natural range of `a`.
28chooseAny :: Random a => Gen a
29chooseAny = MkGen (\r _ -> let (x,_) = random r in x)
39 -- ls = input list (stream)
41 -- tlen = parser take size
44 <$> vectorOf len (chooseAny :: Gen Int)
45 <*> chooseInt (1, len)
46 <*> chooseInt (0, len))
47 $ \(ls, clen, tlen) ->
52 clen (Array.writeN clen) (Stream.fromList ls)
53 parser = ParserD.fromFold (Fold.take tlen Fold.toList)
54 in run $ ArrayStream.parse parser input
55 ls2 <- run $ Stream.toList $ ArrayStream.concat str
56 listEquals (==) (ls1 ++ ls2) ls
58-------------------------------------------------------------------------------
60-------------------------------------------------------------------------------
63moduleName = "Data.Array.Stream.Foreign"
69 modifyMaxSuccess (const maxTestCount) $ do
70 describe moduleName $ do
71 describe "Stream parsing" $ do
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list