@@ -150,21 +150,12 @@ testLastN =
150150 $ S.fromList list
151151 assert (xs == lastN n list)
152152
153−testLastNLT :: Property
154−testLastNLT =
155− forAll (choose (0, maxArrLen)) $ \len ->
156− forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
157− monadicIO $ do
158− xs <- fmap A.toList $ S.fold (A.lastN 0) $ S.fromList list
159− assert (xs == lastN 0 list)
160−
161−testLastNGT :: Property
162−testLastNGT =
163− forAll (choose (0, maxArrLen)) $ \len ->
164− forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
165− monadicIO $ do
166− xs <- fmap A.toList $ S.fold (A.lastN (len + 1)) $ S.fromList list
167− assert (xs == lastN (len + 1) list)
153+testLastN_LN :: Int -> Int -> IO Bool
154+testLastN_LN len n = do
155+ let list = [1..len]
156+ l1 <- fmap A.toList $ S.fold (A.lastN n) $ S.fromList list
157+ let l2 = lastN n list
158+ return $ l1 == l2
168159#endif
169160
170161main :: IO ()
@@ -190,7 +181,10 @@ main =
190181#endif
191182#ifdef TEST_ARRAY
192183 describe "Fold" $ do
193− prop "lastN : 0 <= n < len" $ testLastN
194− prop "lastN : n = 0" $ testLastNLT
195− prop "lastN : n = len + 1" $ testLastNGT
184+ prop "lastN : 0 <= n <= len" $ testLastN
185+ describe "lastN boundary conditions" $ do
186+ it "lastN -1" (testLastN_LN 10 (-1) `shouldReturn` True)
187+ it "lastN 0" (testLastN_LN 10 0 `shouldReturn` True)
188+ it "lastN length" (testLastN_LN 10 10 `shouldReturn` True)
189+ it "lastN (length + 1)" (testLastN_LN 10 11 `shouldReturn` True)
196190#endif