Add my (old) testsuite
[darcs-mirrors/vector.git] / testsuite / Testsuite / Stream / Errors.hs
1 module Testsuite.Stream.Errors ( tests )
2 where
3
4 import Data.Vector.Fusion.Stream ( Stream )
5 import qualified Data.Vector.Fusion.Stream as Stream
6
7 import Testsuite.Utils.Test
8 import Testsuite.Utils.Property
9 import Test.QuickCheck.Batch
10
11 consume :: Stream a -> ()
12 consume = Stream.foldl' (\_ _ -> ()) ()
13
14 prop_headOfEmpty = isBottom (Stream.head (Stream.empty :: Stream A))
15 prop_lastOfEmpty = isBottom (Stream.last (Stream.empty :: Stream A))
16 prop_indexNegative = isBottom (Stream.singleton 5 Stream.!! (-1))
17 prop_indexOutOfRange = isBottom (Stream.singleton 5 Stream.!! 2)
18 prop_initOfEmpty = isBottom (consume (Stream.init Stream.empty))
19 prop_tailOfEmpty = isBottom (consume (Stream.tail Stream.empty))
20 prop_foldl1OfEmpty = isBottom (Stream.foldl1 (\_ _ -> ()) Stream.empty)
21 prop_foldl1'OfEmpty = isBottom (Stream.foldl1' (\_ _ -> ()) Stream.empty)
22 prop_foldr1OfEmpty = isBottom (Stream.foldr1 (\_ _ -> ()) Stream.empty)
23 prop_scanl1OfEmpty
24 = isBottom (consume (Stream.scanl1 (\x _ -> x) Stream.empty))
25 prop_scanl1'OfEmpty
26 = isBottom (consume (Stream.scanl1' (\x _ -> x) Stream.empty))
27
28 tests = "errors" $$? [
29 "head of empty" $? prop_headOfEmpty
30 , "last of empty" $? prop_lastOfEmpty
31 , "negative index" $? prop_indexNegative
32 , "index out of range" $? prop_indexOutOfRange
33 , "init of empty" $? prop_initOfEmpty
34 , "tail of empty" $? prop_tailOfEmpty
35 , "foldl1 of empty" $? prop_foldl1OfEmpty
36 , "foldl1' of empty" $? prop_foldl1'OfEmpty
37 , "foldr1 of empty" $? prop_foldr1OfEmpty
38 , "scanl1 of empty" $? prop_scanl1OfEmpty
39 , "scanl1' of empty" $? prop_scanl1'OfEmpty
40 ]
41