2{-# LANGUAGE FlexibleContexts #-}
4module Main (main) where
6import Data.Char (ord, chr)
7import Data.Word (Word8)
8import Test.Hspec.QuickCheck
10 (Property, forAll, Gen, listOf, arbitraryUnicodeChar, arbitrary)
11import Test.QuickCheck.Monadic (run, monadicIO, assert)
15import qualified Streamly.Mem.Array as A
16import qualified Streamly.Prelude as S
17import qualified Streamly.String as SS
19-- Coverage build takes too long with default number of tests
29-- Use quickcheck-unicode instead?
30genUnicode :: Gen String
31genUnicode = listOf arbitraryUnicodeChar
33genWord8 :: Gen [Word8]
34genWord8 = listOf arbitrary
36propDecodeEncodeId :: Property
38 forAll genUnicode $ \list ->
40 let wrds = SS.encodeUtf8 $ S.fromList list
41 chrs <- S.toList $ SS.decodeUtf8 wrds
46 forAll genUnicode $ \list ->
52 assert (xs == lines list)
54testLinesArray :: Property
56 forAll genWord8 $ \list ->
61 $ S.yield (A.fromList list)
62 assert (xs == map (map (fromIntegral . ord))
63 (lines (map (chr . fromIntegral) list)))
67 forAll genUnicode $ \list ->
73 assert (xs == words list)
75testUnlines :: Property
77 forAll genUnicode $ \list ->
83 assert (xs == unlines (lines list))
85testUnwords :: Property
87 forAll genUnicode $ \list ->
94 assert (xs == unwords (words list))
99 $ modifyMaxSuccess (const 1000)
101 describe "UTF8 - Encoding / Decoding" $ do
102 prop "decodeUtf8 . encodeUtf8 == id" $ propDecodeEncodeId
103 prop "Streamly.String.lines == Prelude.lines" $ testLines
104 prop "Arrays Streamly.String.lines == Prelude.lines" $ testLinesArray
105 prop "Streamly.String.words == Prelude.words" $ testWords
107 "Streamly.String.unlines . Streamly.String.lines == unlines . lines"
110 "Streamly.String.unwords . Streamly.String.words == unwords . words"
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