@@ -132,26 +132,44 @@ testArraysOf =
132 $ IP.arraysOf 240
132 $ IP.arraysOf 240
133 $ S.fromList list
133 $ S.fromList list
134 assert (xs == list)
134 assert (xs == list)
136+lastN :: Int -> [a] -> [a]
137+lastN n l = drop (length l - n) l
139+testLastN :: Property
141+ forAll (choose (0, maxArrLen)) $ \len ->
142+ forAll (choose (0, len)) $ \n ->
143+ forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
146+ $ S.fold (A.lastN n)
148+ assert (xs == lastN n list)
137main :: IO ()
151main :: IO ()
140 H.parallel $
154 H.parallel $
141− modifyMaxSuccess (const maxTestCount) $
155+ modifyMaxSuccess (const maxTestCount) $ do
142− describe "Construction" $ do
156+ describe "Construction" $ do
143− prop "length . writeN n === n" testLength
157+ prop "length . writeN n === n" testLength
144− prop "length . fromStreamN n === n" testLengthFromStreamN
158+ prop "length . fromStreamN n === n" testLengthFromStreamN
145− prop "read . writeN === id " testFoldNUnfold
159+ prop "read . writeN === id " testFoldNUnfold
146− prop "toStream . writeN === id" testFoldNToStream
160+ prop "toStream . writeN === id" testFoldNToStream
147− prop "toStreamRev . writeN === reverse" testFoldNToStreamRev
161+ prop "toStreamRev . writeN === reverse" testFoldNToStreamRev
148− prop "read . fromStreamN === id" testFromStreamNUnfold
162+ prop "read . fromStreamN === id" testFromStreamNUnfold
149− prop "toStream . fromStreamN === id" testFromStreamNToStream
163+ prop "toStream . fromStreamN === id" testFromStreamNToStream
150#ifndef TEST_SMALL_ARRAY
164#ifndef TEST_SMALL_ARRAY
151− prop "length . fromStream === n" testLengthFromStream
165+ prop "length . fromStream === n" testLengthFromStream
152− prop "toStream . fromStream === id" testFromStreamToStream
166+ prop "toStream . fromStream === id" testFromStreamToStream
153− prop "read . write === id" testFoldUnfold
167+ prop "read . write === id" testFoldUnfold
170+ prop "arraysOf concats to original" testArraysOf
155#ifdef TEST_ARRAY
172#ifdef TEST_ARRAY
156− prop "arraysOf concats to original" testArraysOf
173+ describe "Fold" $ do
174+ prop "lastN" $ testLastN