Add tests
[darcs-mirrors/vector.git] / tests / Tests / Vector.hs
1 module Tests.Vector (tests) where
2
3 import Boilerplater
4 import Utilities
5
6 import qualified Data.Vector.Generic as V
7 import qualified Data.Vector
8 import qualified Data.Vector.Primitive
9 import qualified Data.Vector.Storable
10 import qualified Data.Vector.Unboxed
11 import qualified Data.Vector.Fusion.Stream as S
12
13 import Test.QuickCheck
14
15 import Test.Framework
16 import Test.Framework.Providers.QuickCheck2
17
18 import Text.Show.Functions ()
19 import Data.List
20 import System.Random (Random)
21
22 #define COMMON_CONTEXT(a, v) \
23 VANILLA_CONTEXT(a, v), VECTOR_CONTEXT(a, v)
24
25 #define VANILLA_CONTEXT(a, v) \
26 Eq a, Show a, Arbitrary a, CoArbitrary a, TestData a, Model a ~ a, EqTest a ~ Property
27
28 #define VECTOR_CONTEXT(a, v) \
29 Eq (v a), Show (v a), Arbitrary (v a), CoArbitrary (v a), TestData (v a), Model (v a) ~ [a], EqTest (v a) ~ Property, V.Vector v a
30
31 -- TODO: implement Vector equivalents of list functions for some of the commented out properties
32
33 -- TODO: test and implement some of these other Prelude functions:
34 -- mapM *
35 -- mapM_ *
36 -- sequence
37 -- sequence_
38 -- sum *
39 -- product *
40 -- scanl *
41 -- scanl1 *
42 -- scanr *
43 -- scanr1 *
44 -- lookup *
45 -- lines
46 -- words
47 -- unlines
48 -- unwords
49 -- NB: this is an exhaustive list of all Prelude list functions that make sense for vectors.
50 -- Ones with *s are the most plausible candidates.
51
52 -- TODO: add tests for the other extra functions
53 -- IVector exports still needing tests:
54 -- copy,
55 -- slice,
56 -- (//), update, bpermute,
57 -- prescanl, prescanl',
58 -- new,
59 -- unsafeSlice, unsafeIndex,
60 -- vlength, vnew
61
62 -- TODO: test non-IVector stuff?
63
64 testSanity :: forall a v. (COMMON_CONTEXT(a, v)) => v a -> [Test]
65 testSanity _ = [
66 testProperty "fromList.toList == id" prop_fromList_toList,
67 testProperty "toList.fromList == id" prop_toList_fromList,
68 testProperty "unstream.stream == id" prop_unstream_stream,
69 testProperty "stream.unstream == id" prop_stream_unstream
70 ]
71 where
72 prop_fromList_toList (v :: v a) = (V.fromList . V.toList) v == v
73 prop_toList_fromList (l :: [a]) = ((V.toList :: v a -> [a]) . V.fromList) l == l
74 prop_unstream_stream (v :: v a) = (V.unstream . V.stream) v == v
75 prop_stream_unstream (s :: S.Stream a) = ((V.stream :: v a -> S.Stream a) . V.unstream) s == s
76
77 testPolymorphicFunctions :: forall a v. (COMMON_CONTEXT(a, v), VECTOR_CONTEXT(Int, v)) => v a -> [Test]
78 testPolymorphicFunctions _ = $(testProperties [
79 'prop_eq,
80
81 -- Length information
82 'prop_length, 'prop_null,
83
84 -- Indexing (FIXME)
85 'prop_index, 'prop_safeIndex, 'prop_head, 'prop_last,
86 'prop_unsafeIndex, 'prop_unsafeHead, 'prop_unsafeLast,
87
88 -- Monadic indexing (FIXME)
89 {- 'prop_indexM, 'prop_headM, 'prop_lastM,
90 'prop_unsafeIndexM, 'prop_unsafeHeadM, 'prop_unsafeLastM, -}
91
92 -- Subvectors (FIXME)
93 'prop_slice, 'prop_init, 'prop_tail, 'prop_take, 'prop_drop,
94 'prop_splitAt,
95 {- 'prop_unsafeSlice, 'prop_unsafeInit, 'prop_unsafeTail,
96 'prop_unsafeTake, 'prop_unsafeDrop, -}
97
98 -- Initialisation (FIXME)
99 'prop_empty, 'prop_singleton, 'prop_replicate,
100 'prop_generate, 'prop_iterateN,
101
102 -- Monadic initialisation (FIXME)
103 {- 'prop_replicateM, 'prop_generateM, 'prop_create, -}
104
105 -- Unfolding (FIXME)
106 {- 'prop_unfoldr, prop_unfoldrN, -}
107 'prop_constructN, 'prop_constructrN,
108
109 -- Enumeration? (FIXME?)
110
111 -- Concatenation (FIXME)
112 'prop_cons, 'prop_snoc, 'prop_append,
113 'prop_concat,
114
115 -- Restricting memory usage
116 'prop_force,
117
118
119 -- Bulk updates (FIXME)
120 'prop_upd,
121 {- 'prop_update, 'prop_update_,
122 'prop_unsafeUpd, 'prop_unsafeUpdate, 'prop_unsafeUpdate_, -}
123
124 -- Accumulations (FIXME)
125 'prop_accum,
126 {- 'prop_accumulate, 'prop_accumulate_,
127 'prop_unsafeAccum, 'prop_unsafeAccumulate, 'prop_unsafeAccumulate_, -}
128
129 -- Permutations
130 'prop_reverse, 'prop_backpermute,
131 {- 'prop_unsafeBackpermute, -}
132
133 -- Elementwise indexing
134 {- 'prop_indexed, -}
135
136 -- Mapping
137 'prop_map, 'prop_imap, 'prop_concatMap,
138
139 -- Monadic mapping
140 {- 'prop_mapM, 'prop_mapM_, 'prop_forM, 'prop_forM_, -}
141
142 -- Zipping
143 'prop_zipWith, 'prop_zipWith3, {- ... -}
144 'prop_izipWith, 'prop_izipWith3, {- ... -}
145 {- 'prop_zip, ... -}
146
147 -- Monadic zipping
148 {- 'prop_zipWithM, 'prop_zipWithM_, -}
149
150 -- Unzipping
151 {- 'prop_unzip, ... -}
152
153 -- Filtering
154 'prop_filter, 'prop_ifilter, {- prop_filterM, -}
155 'prop_takeWhile, 'prop_dropWhile,
156
157 -- Paritioning
158 'prop_partition, {- 'prop_unstablePartition, -}
159 'prop_span, 'prop_break,
160
161 -- Searching
162 'prop_elem, 'prop_notElem,
163 'prop_find, 'prop_findIndex, 'prop_findIndices,
164 'prop_elemIndex, 'prop_elemIndices,
165
166 -- Folding
167 'prop_foldl, 'prop_foldl1, 'prop_foldl', 'prop_foldl1',
168 'prop_foldr, 'prop_foldr1, 'prop_foldr', 'prop_foldr1',
169 'prop_ifoldl, 'prop_ifoldl', 'prop_ifoldr, 'prop_ifoldr',
170
171 -- Specialised folds
172 'prop_all, 'prop_any,
173 {- 'prop_maximumBy, 'prop_minimumBy,
174 'prop_maxIndexBy, 'prop_minIndexBy, -}
175
176 -- Monadic folds
177 {- ... -}
178
179 -- Monadic sequencing
180 {- ... -}
181
182 -- Scans
183 'prop_prescanl, 'prop_prescanl',
184 'prop_postscanl, 'prop_postscanl',
185 'prop_scanl, 'prop_scanl', 'prop_scanl1, 'prop_scanl1',
186
187 'prop_prescanr, 'prop_prescanr',
188 'prop_postscanr, 'prop_postscanr',
189 'prop_scanr, 'prop_scanr', 'prop_scanr1, 'prop_scanr1'
190 ])
191 where
192 -- Prelude
193 prop_eq :: P (v a -> v a -> Bool) = (==) `eq` (==)
194
195 prop_length :: P (v a -> Int) = V.length `eq` length
196 prop_null :: P (v a -> Bool) = V.null `eq` null
197
198 prop_empty :: P (v a) = V.empty `eq` []
199 prop_singleton :: P (a -> v a) = V.singleton `eq` singleton
200 prop_replicate :: P (Int -> a -> v a)
201 = (\n _ -> n < 1000) ===> V.replicate `eq` replicate
202 prop_cons :: P (a -> v a -> v a) = V.cons `eq` (:)
203 prop_snoc :: P (v a -> a -> v a) = V.snoc `eq` snoc
204 prop_append :: P (v a -> v a -> v a) = (V.++) `eq` (++)
205 prop_concat :: P ([v a] -> v a) = V.concat `eq` concat
206 prop_force :: P (v a -> v a) = V.force `eq` id
207 prop_generate :: P (Int -> (Int -> a) -> v a)
208 = (\n _ -> n < 1000) ===> V.generate `eq` generate
209 prop_iterateN :: P (Int -> (a -> a) -> a -> v a)
210 = (\n _ _ -> n < 1000) ===> V.iterateN `eq` (\n f -> take n . iterate f)
211
212 prop_head :: P (v a -> a) = not . V.null ===> V.head `eq` head
213 prop_last :: P (v a -> a) = not . V.null ===> V.last `eq` last
214 prop_index = \xs ->
215 not (V.null xs) ==>
216 forAll (choose (0, V.length xs-1)) $ \i ->
217 unP prop xs i
218 where
219 prop :: P (v a -> Int -> a) = (V.!) `eq` (!!)
220 prop_safeIndex :: P (v a -> Int -> Maybe a) = (V.!?) `eq` fn
221 where
222 fn xs i = case drop i xs of
223 x:_ | i >= 0 -> Just x
224 _ -> Nothing
225 prop_unsafeHead :: P (v a -> a) = not . V.null ===> V.unsafeHead `eq` head
226 prop_unsafeLast :: P (v a -> a) = not . V.null ===> V.unsafeLast `eq` last
227 prop_unsafeIndex = \xs ->
228 not (V.null xs) ==>
229 forAll (choose (0, V.length xs-1)) $ \i ->
230 unP prop xs i
231 where
232 prop :: P (v a -> Int -> a) = V.unsafeIndex `eq` (!!)
233
234 prop_slice = \xs ->
235 forAll (choose (0, V.length xs)) $ \i ->
236 forAll (choose (0, V.length xs - i)) $ \n ->
237 unP prop i n xs
238 where
239 prop :: P (Int -> Int -> v a -> v a) = V.slice `eq` slice
240
241 prop_tail :: P (v a -> v a) = not . V.null ===> V.tail `eq` tail
242 prop_init :: P (v a -> v a) = not . V.null ===> V.init `eq` init
243 prop_take :: P (Int -> v a -> v a) = V.take `eq` take
244 prop_drop :: P (Int -> v a -> v a) = V.drop `eq` drop
245 prop_splitAt :: P (Int -> v a -> (v a, v a)) = V.splitAt `eq` splitAt
246
247 prop_accum = \f xs ->
248 forAll (index_value_pairs (V.length xs)) $ \ps ->
249 unP prop f xs ps
250 where
251 prop :: P ((a -> a -> a) -> v a -> [(Int,a)] -> v a)
252 = V.accum `eq` accum
253
254 prop_upd = \xs ->
255 forAll (index_value_pairs (V.length xs)) $ \ps ->
256 unP prop xs ps
257 where
258 prop :: P (v a -> [(Int,a)] -> v a) = (V.//) `eq` (//)
259
260 prop_backpermute = \xs ->
261 forAll (indices (V.length xs)) $ \is ->
262 unP prop xs (V.fromList is)
263 where
264 prop :: P (v a -> v Int -> v a) = V.backpermute `eq` backpermute
265
266 prop_reverse :: P (v a -> v a) = V.reverse `eq` reverse
267
268 prop_map :: P ((a -> a) -> v a -> v a) = V.map `eq` map
269 prop_zipWith :: P ((a -> a -> a) -> v a -> v a -> v a) = V.zipWith `eq` zipWith
270 prop_zipWith3 :: P ((a -> a -> a -> a) -> v a -> v a -> v a -> v a)
271 = V.zipWith3 `eq` zipWith3
272 prop_imap :: P ((Int -> a -> a) -> v a -> v a) = V.imap `eq` imap
273 prop_izipWith :: P ((Int -> a -> a -> a) -> v a -> v a -> v a) = V.izipWith `eq` izipWith
274 prop_izipWith3 :: P ((Int -> a -> a -> a -> a) -> v a -> v a -> v a -> v a)
275 = V.izipWith3 `eq` izipWith3
276
277 prop_filter :: P ((a -> Bool) -> v a -> v a) = V.filter `eq` filter
278 prop_ifilter :: P ((Int -> a -> Bool) -> v a -> v a) = V.ifilter `eq` ifilter
279 prop_takeWhile :: P ((a -> Bool) -> v a -> v a) = V.takeWhile `eq` takeWhile
280 prop_dropWhile :: P ((a -> Bool) -> v a -> v a) = V.dropWhile `eq` dropWhile
281 prop_partition :: P ((a -> Bool) -> v a -> (v a, v a))
282 = V.partition `eq` partition
283 prop_span :: P ((a -> Bool) -> v a -> (v a, v a)) = V.span `eq` span
284 prop_break :: P ((a -> Bool) -> v a -> (v a, v a)) = V.break `eq` break
285
286 prop_elem :: P (a -> v a -> Bool) = V.elem `eq` elem
287 prop_notElem :: P (a -> v a -> Bool) = V.notElem `eq` notElem
288 prop_find :: P ((a -> Bool) -> v a -> Maybe a) = V.find `eq` find
289 prop_findIndex :: P ((a -> Bool) -> v a -> Maybe Int)
290 = V.findIndex `eq` findIndex
291 prop_findIndices :: P ((a -> Bool) -> v a -> v Int)
292 = V.findIndices `eq` findIndices
293 prop_elemIndex :: P (a -> v a -> Maybe Int) = V.elemIndex `eq` elemIndex
294 prop_elemIndices :: P (a -> v a -> v Int) = V.elemIndices `eq` elemIndices
295
296 prop_foldl :: P ((a -> a -> a) -> a -> v a -> a) = V.foldl `eq` foldl
297 prop_foldl1 :: P ((a -> a -> a) -> v a -> a) = notNull2 ===>
298 V.foldl1 `eq` foldl1
299 prop_foldl' :: P ((a -> a -> a) -> a -> v a -> a) = V.foldl' `eq` foldl'
300 prop_foldl1' :: P ((a -> a -> a) -> v a -> a) = notNull2 ===>
301 V.foldl1' `eq` foldl1'
302 prop_foldr :: P ((a -> a -> a) -> a -> v a -> a) = V.foldr `eq` foldr
303 prop_foldr1 :: P ((a -> a -> a) -> v a -> a) = notNull2 ===>
304 V.foldr1 `eq` foldr1
305 prop_foldr' :: P ((a -> a -> a) -> a -> v a -> a) = V.foldr' `eq` foldr
306 prop_foldr1' :: P ((a -> a -> a) -> v a -> a) = notNull2 ===>
307 V.foldr1' `eq` foldr1
308 prop_ifoldl :: P ((a -> Int -> a -> a) -> a -> v a -> a)
309 = V.ifoldl `eq` ifoldl
310 prop_ifoldl' :: P ((a -> Int -> a -> a) -> a -> v a -> a)
311 = V.ifoldl' `eq` ifoldl
312 prop_ifoldr :: P ((Int -> a -> a -> a) -> a -> v a -> a)
313 = V.ifoldr `eq` ifoldr
314 prop_ifoldr' :: P ((Int -> a -> a -> a) -> a -> v a -> a)
315 = V.ifoldr' `eq` ifoldr
316
317 prop_all :: P ((a -> Bool) -> v a -> Bool) = V.all `eq` all
318 prop_any :: P ((a -> Bool) -> v a -> Bool) = V.any `eq` any
319
320 prop_prescanl :: P ((a -> a -> a) -> a -> v a -> v a)
321 = V.prescanl `eq` prescanl
322 prop_prescanl' :: P ((a -> a -> a) -> a -> v a -> v a)
323 = V.prescanl' `eq` prescanl
324 prop_postscanl :: P ((a -> a -> a) -> a -> v a -> v a)
325 = V.postscanl `eq` postscanl
326 prop_postscanl' :: P ((a -> a -> a) -> a -> v a -> v a)
327 = V.postscanl' `eq` postscanl
328 prop_scanl :: P ((a -> a -> a) -> a -> v a -> v a)
329 = V.scanl `eq` scanl
330 prop_scanl' :: P ((a -> a -> a) -> a -> v a -> v a)
331 = V.scanl' `eq` scanl
332 prop_scanl1 :: P ((a -> a -> a) -> v a -> v a) = notNull2 ===>
333 V.scanl1 `eq` scanl1
334 prop_scanl1' :: P ((a -> a -> a) -> v a -> v a) = notNull2 ===>
335 V.scanl1' `eq` scanl1
336
337 prop_prescanr :: P ((a -> a -> a) -> a -> v a -> v a)
338 = V.prescanr `eq` prescanr
339 prop_prescanr' :: P ((a -> a -> a) -> a -> v a -> v a)
340 = V.prescanr' `eq` prescanr
341 prop_postscanr :: P ((a -> a -> a) -> a -> v a -> v a)
342 = V.postscanr `eq` postscanr
343 prop_postscanr' :: P ((a -> a -> a) -> a -> v a -> v a)
344 = V.postscanr' `eq` postscanr
345 prop_scanr :: P ((a -> a -> a) -> a -> v a -> v a)
346 = V.scanr `eq` scanr
347 prop_scanr' :: P ((a -> a -> a) -> a -> v a -> v a)
348 = V.scanr' `eq` scanr
349 prop_scanr1 :: P ((a -> a -> a) -> v a -> v a) = notNull2 ===>
350 V.scanr1 `eq` scanr1
351 prop_scanr1' :: P ((a -> a -> a) -> v a -> v a) = notNull2 ===>
352 V.scanr1' `eq` scanr1
353
354 prop_concatMap = forAll arbitrary $ \xs ->
355 forAll (sized (\n -> resize (n `div` V.length xs) arbitrary)) $ \f -> unP prop f xs
356 where
357 prop :: P ((a -> v a) -> v a -> v a) = V.concatMap `eq` concatMap
358
359 --prop_span = (V.span :: (a -> Bool) -> v a -> (v a, v a)) `eq2` span
360 --prop_break = (V.break :: (a -> Bool) -> v a -> (v a, v a)) `eq2` break
361 --prop_splitAt = (V.splitAt :: Int -> v a -> (v a, v a)) `eq2` splitAt
362 --prop_all = (V.all :: (a -> Bool) -> v a -> Bool) `eq2` all
363 --prop_any = (V.any :: (a -> Bool) -> v a -> Bool) `eq2` any
364
365 -- Data.List
366 --prop_findIndices = V.findIndices `eq2` (findIndices :: (a -> Bool) -> v a -> v Int)
367 --prop_isPrefixOf = V.isPrefixOf `eq2` (isPrefixOf :: v a -> v a -> Bool)
368 --prop_elemIndex = V.elemIndex `eq2` (elemIndex :: a -> v a -> Maybe Int)
369 --prop_elemIndices = V.elemIndices `eq2` (elemIndices :: a -> v a -> v Int)
370 --
371 --prop_mapAccumL = eq3
372 -- (V.mapAccumL :: (X -> W -> (X,W)) -> X -> B -> (X, B))
373 -- ( mapAccumL :: (X -> W -> (X,W)) -> X -> [W] -> (X, [W]))
374 --
375 --prop_mapAccumR = eq3
376 -- (V.mapAccumR :: (X -> W -> (X,W)) -> X -> B -> (X, B))
377 -- ( mapAccumR :: (X -> W -> (X,W)) -> X -> [W] -> (X, [W]))
378
379 -- Because the vectors are strict, we need to be totally sure that the unfold eventually terminates. This
380 -- is achieved by injecting our own bit of state into the unfold - the maximum number of unfolds allowed.
381 limitUnfolds f (theirs, ours) | ours >= 0
382 , Just (out, theirs') <- f theirs = Just (out, (theirs', ours - 1))
383 | otherwise = Nothing
384 prop_unfoldr :: P (Int -> (Int -> Maybe (a,Int)) -> Int -> v a)
385 = (\n f a -> V.unfoldr (limitUnfolds f) (a, n))
386 `eq` (\n f a -> unfoldr (limitUnfolds f) (a, n))
387
388 prop_constructN = \f -> forAll (choose (0,20)) $ \n -> unP prop n f
389 where
390 prop :: P (Int -> (v a -> a) -> v a) = V.constructN `eq` constructN []
391
392 constructN xs 0 _ = xs
393 constructN xs n f = constructN (xs ++ [f xs]) (n-1) f
394
395 prop_constructrN = \f -> forAll (choose (0,20)) $ \n -> unP prop n f
396 where
397 prop :: P (Int -> (v a -> a) -> v a) = V.constructrN `eq` constructrN []
398
399 constructrN xs 0 _ = xs
400 constructrN xs n f = constructrN (f xs : xs) (n-1) f
401
402 testTuplyFunctions:: forall a v. (COMMON_CONTEXT(a, v), VECTOR_CONTEXT((a, a), v), VECTOR_CONTEXT((a, a, a), v)) => v a -> [Test]
403 testTuplyFunctions _ = $(testProperties ['prop_zip, 'prop_zip3, 'prop_unzip, 'prop_unzip3])
404 where
405 prop_zip :: P (v a -> v a -> v (a, a)) = V.zip `eq` zip
406 prop_zip3 :: P (v a -> v a -> v a -> v (a, a, a)) = V.zip3 `eq` zip3
407 prop_unzip :: P (v (a, a) -> (v a, v a)) = V.unzip `eq` unzip
408 prop_unzip3 :: P (v (a, a, a) -> (v a, v a, v a)) = V.unzip3 `eq` unzip3
409
410 testOrdFunctions :: forall a v. (COMMON_CONTEXT(a, v), Ord a, Ord (v a)) => v a -> [Test]
411 testOrdFunctions _ = $(testProperties
412 ['prop_compare,
413 'prop_maximum, 'prop_minimum,
414 'prop_minIndex, 'prop_maxIndex ])
415 where
416 prop_compare :: P (v a -> v a -> Ordering) = compare `eq` compare
417 prop_maximum :: P (v a -> a) = not . V.null ===> V.maximum `eq` maximum
418 prop_minimum :: P (v a -> a) = not . V.null ===> V.minimum `eq` minimum
419 prop_minIndex :: P (v a -> Int) = not . V.null ===> V.minIndex `eq` minIndex
420 prop_maxIndex :: P (v a -> Int) = not . V.null ===> V.maxIndex `eq` maxIndex
421
422 testEnumFunctions :: forall a v. (COMMON_CONTEXT(a, v), Enum a, Ord a, Num a, Random a) => v a -> [Test]
423 testEnumFunctions _ = $(testProperties
424 [ 'prop_enumFromN, 'prop_enumFromThenN,
425 'prop_enumFromTo, 'prop_enumFromThenTo])
426 where
427 prop_enumFromN :: P (a -> Int -> v a)
428 = (\_ n -> n < 1000)
429 ===> V.enumFromN `eq` (\x n -> take n $ scanl (+) x $ repeat 1)
430
431 prop_enumFromThenN :: P (a -> a -> Int -> v a)
432 = (\_ _ n -> n < 1000)
433 ===> V.enumFromStepN `eq` (\x y n -> take n $ scanl (+) x $ repeat y)
434
435 prop_enumFromTo = \m ->
436 forAll (choose (-2,100)) $ \n ->
437 unP prop m (m+n)
438 where
439 prop :: P (a -> a -> v a) = V.enumFromTo `eq` enumFromTo
440
441 prop_enumFromThenTo = \i j ->
442 j /= i ==>
443 forAll (choose (ks i j)) $ \k ->
444 unP prop i j k
445 where
446 prop :: P (a -> a -> a -> v a) = V.enumFromThenTo `eq` enumFromThenTo
447
448 ks i j | j < i = (i-d*100, i+d*2)
449 | otherwise = (i-d*2, i+d*100)
450 where
451 d = abs (j-i)
452
453 testBoolFunctions :: forall v. (COMMON_CONTEXT(Bool, v)) => v Bool -> [Test]
454 testBoolFunctions _ = $(testProperties ['prop_and, 'prop_or])
455 where
456 prop_and :: P (v Bool -> Bool) = V.and `eq` and
457 prop_or :: P (v Bool -> Bool) = V.or `eq` or
458
459 testNumFunctions :: forall a v. (COMMON_CONTEXT(a, v), Num a) => v a -> [Test]
460 testNumFunctions _ = $(testProperties ['prop_sum, 'prop_product])
461 where
462 prop_sum :: P (v a -> a) = V.sum `eq` sum
463 prop_product :: P (v a -> a) = V.product `eq` product
464
465 testNestedVectorFunctions :: forall a v. (COMMON_CONTEXT(a, v)) => v a -> [Test]
466 testNestedVectorFunctions _ = $(testProperties [])
467 where
468 -- Prelude
469 --prop_concat = (V.concat :: [v a] -> v a) `eq1` concat
470
471 -- Data.List
472 --prop_transpose = V.transpose `eq1` (transpose :: [v a] -> [v a])
473 --prop_group = V.group `eq1` (group :: v a -> [v a])
474 --prop_inits = V.inits `eq1` (inits :: v a -> [v a])
475 --prop_tails = V.tails `eq1` (tails :: v a -> [v a])
476
477
478 testGeneralBoxedVector dummy = concatMap ($ dummy) [
479 testSanity,
480 testPolymorphicFunctions,
481 testOrdFunctions,
482 testTuplyFunctions,
483 testNestedVectorFunctions
484 ]
485
486 testBoolBoxedVector dummy = concatMap ($ dummy)
487 [
488 testGeneralBoxedVector
489 , testBoolFunctions
490 ]
491
492 testNumericBoxedVector dummy = concatMap ($ dummy)
493 [
494 testGeneralBoxedVector
495 , testNumFunctions
496 , testEnumFunctions
497 ]
498
499
500
501 testGeneralPrimitiveVector dummy = concatMap ($ dummy) [
502 testSanity,
503 testPolymorphicFunctions,
504 testOrdFunctions
505 ]
506
507 testBoolPrimitiveVector dummy = concatMap ($ dummy)
508 [
509 testGeneralPrimitiveVector
510 , testBoolFunctions
511 ]
512
513 testNumericPrimitiveVector dummy = concatMap ($ dummy)
514 [
515 testGeneralPrimitiveVector
516 , testNumFunctions
517 , testEnumFunctions
518 ]
519
520
521
522 testGeneralStorableVector dummy = concatMap ($ dummy) [
523 testSanity,
524 testPolymorphicFunctions,
525 testOrdFunctions
526 ]
527
528 testNumericStorableVector dummy = concatMap ($ dummy)
529 [
530 testGeneralStorableVector
531 , testNumFunctions
532 , testEnumFunctions
533 ]
534
535
536
537 testGeneralUnboxedVector dummy = concatMap ($ dummy) [
538 testSanity,
539 testPolymorphicFunctions,
540 testOrdFunctions
541 ]
542
543 testUnitUnboxedVector dummy = concatMap ($ dummy)
544 [
545 testGeneralUnboxedVector
546 ]
547
548 testBoolUnboxedVector dummy = concatMap ($ dummy)
549 [
550 testGeneralUnboxedVector
551 , testBoolFunctions
552 ]
553
554 testNumericUnboxedVector dummy = concatMap ($ dummy)
555 [
556 testGeneralUnboxedVector
557 , testNumFunctions
558 , testEnumFunctions
559 ]
560
561 testTupleUnboxedVector dummy = concatMap ($ dummy)
562 [
563 testGeneralUnboxedVector
564 ]
565
566 tests = [
567 testGroup "Data.Vector.Vector (Bool)" (testBoolBoxedVector (undefined :: Data.Vector.Vector Bool)),
568 testGroup "Data.Vector.Vector (Int)" (testNumericBoxedVector (undefined :: Data.Vector.Vector Int)),
569
570 testGroup "Data.Vector.Primitive.Vector (Int)" (testNumericPrimitiveVector (undefined :: Data.Vector.Primitive.Vector Int)),
571 testGroup "Data.Vector.Primitive.Vector (Double)" (testNumericPrimitiveVector (undefined :: Data.Vector.Primitive.Vector Double)),
572
573 testGroup "Data.Vector.Storable.Vector (Int)" (testNumericStorableVector (undefined :: Data.Vector.Storable.Vector Int)),
574 testGroup "Data.Vector.Storable.Vector (Double)" (testNumericStorableVector (undefined :: Data.Vector.Storable.Vector Double)),
575
576 testGroup "Data.Vector.Unboxed.Vector ()" (testUnitUnboxedVector (undefined :: Data.Vector.Unboxed.Vector ())),
577 testGroup "Data.Vector.Unboxed.Vector (Int)" (testNumericUnboxedVector (undefined :: Data.Vector.Unboxed.Vector Int)),
578 testGroup "Data.Vector.Unboxed.Vector (Double)" (testNumericUnboxedVector (undefined :: Data.Vector.Unboxed.Vector Double)),
579 testGroup "Data.Vector.Unboxed.Vector (Int,Bool)" (testTupleUnboxedVector (undefined :: Data.Vector.Unboxed.Vector (Int,Bool))),
580 testGroup "Data.Vector.Unboxed.Vector (Int,Bool,Int)" (testTupleUnboxedVector (undefined :: Data.Vector.Unboxed.Vector (Int,Bool,Int)))
581
582 ]
583