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.Mem.Array.Stream as AS
17import qualified Streamly.Prelude as S
18import qualified Streamly.String as SS
20-- Coverage build takes too long with default number of tests
30-- Use quickcheck-unicode instead?
31genUnicode :: Gen String
32genUnicode = listOf arbitraryUnicodeChar
34genWord8 :: Gen [Word8]
35genWord8 = listOf arbitrary
37propDecodeEncodeId :: Property
39 forAll genUnicode $ \list ->
41 let wrds = SS.encodeUtf8 $ S.fromList list
42 chrs <- S.toList $ SS.decodeUtf8 wrds
47 forAll genUnicode $ \list ->
53 assert (xs == lines list)
55testLinesArray :: Property
57 forAll genWord8 $ \list ->
62 $ S.yield (A.fromList list)
63 assert (xs == map (map (fromIntegral . ord))
64 (lines (map (chr . fromIntegral) list)))
68 forAll genUnicode $ \list ->
74 assert (xs == words list)
76testUnlines :: Property
78 forAll genUnicode $ \list ->
84 assert (xs == unlines (lines list))
86testUnwords :: Property
88 forAll genUnicode $ \list ->
95 assert (xs == unwords (words list))
100 $ modifyMaxSuccess (const 1000)
102 describe "UTF8 - Encoding / Decoding" $ do
103 prop "decodeUtf8 . encodeUtf8 == id" $ propDecodeEncodeId
104 prop "Streamly.String.lines == Prelude.lines" $ testLines
105 prop "Arrays Streamly.String.lines == Prelude.lines" $ testLinesArray
106 prop "Streamly.String.words == Prelude.words" $ testWords
108 "Streamly.String.unlines . Streamly.String.lines == unlines . lines"
111 "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