4-- Coverage build takes too long with default number of tests
13maxArrLen = defaultChunkSize * 8
16 (Int -> Stream IO Int -> IO (Array Int))
18genericTestFrom arrFold =
19 forAll (choose (0, maxArrLen)) $ \len ->
20 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
22 arr <- run $ arrFold len $ S.fromList list
23 assert (A.length arr == len)
26testLength = genericTestFrom (S.fold . A.writeN)
28testLengthFromStreamN :: Property
29testLengthFromStreamN = genericTestFrom A.fromStreamN
32 (Int -> Stream IO Int -> IO (Array Int))
33 -> (Array Int -> Stream IO Int)
34 -> ([Int] -> [Int] -> Bool)
36genericTestFromTo arrFold arrUnfold listEq =
37 forAll (choose (0, maxArrLen)) $ \len ->
38 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
40 arr <- run $ arrFold len $ S.fromList list
41 xs <- run $ S.fold Fold.toList $ arrUnfold arr
42 assert (listEq xs list)
45testFoldNUnfold :: Property
47 genericTestFromTo (S.fold . A.writeN) (S.unfold A.reader) (==)
49testFoldNToStream :: Property
51 genericTestFromTo (S.fold . A.writeN) A.read (==)
53testFoldNToStreamRev :: Property
58 (\xs list -> xs == reverse list)
60testFromStreamNUnfold :: Property
61testFromStreamNUnfold =
62 genericTestFromTo A.fromStreamN (S.unfold A.reader) (==)
64testFromStreamNToStream :: Property
65testFromStreamNToStream = genericTestFromTo A.fromStreamN A.read (==)
67testFromListN :: Property
69 forAll (choose (0, maxArrLen)) $ \len ->
70 forAll (choose (0, len)) $ \n ->
71 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
73 let arr = A.fromListN n list
74 xs <- run $ S.fold Fold.toList $ S.unfold A.reader arr
75 listEquals (==) xs (take n list)
77foldManyWith :: (Int -> Fold IO Int (Array Int)) -> Property
79 forAll (choose (0, maxArrLen)) $ \len ->
80 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
84 $ S.unfoldMany A.reader
89commonMain :: SpecWith ()
91 describe "Construction" $ do
92 prop "length . writeN n === n" testLength
93 prop "length . fromStreamN n === n" testLengthFromStreamN
94 prop "read . writeN === id " testFoldNUnfold
95 prop "toStream . writeN === id" testFoldNToStream
96 prop "toStreamRev . writeN === reverse" testFoldNToStreamRev
97 prop "read . fromStreamN === id" testFromStreamNUnfold
98 prop "toStream . fromStreamN === id" testFromStreamNToStream
99 prop "fromListN" testFromListN
100 prop "foldMany with writeN concats to original"
101 (foldManyWith A.writeN)
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