X-Git-Url: http://git.haskell.org/darcs-mirrors/vector.git/blobdiff_plain/31ff9c9e3d27f87bf454b14c005468d03249ed3f..0518a4a2f7c01d066acf603de42779eb56033506:/tests/Utilities.hs
diff --git a/tests/Utilities.hs b/tests/Utilities.hs
index 162d0c8..e0129f2 100644
--- a/tests/Utilities.hs
+++ b/tests/Utilities.hs
@@ -7,13 +7,14 @@ import qualified Data.Vector as DV
import qualified Data.Vector.Generic as DVG
import qualified Data.Vector.Primitive as DVP
import qualified Data.Vector.Storable as DVS
-import qualified Data.Vector.Fusion.Stream as S
+import qualified Data.Vector.Unboxed as DVU
+import qualified Data.Vector.Fusion.Bundle as S
import Data.List ( sortBy )
-instance Show a => Show (S.Stream a) where
- show s = "Data.Vector.Fusion.Stream.fromList " ++ show (S.toList s)
+instance Show a => Show (S.Bundle v a) where
+ show s = "Data.Vector.Fusion.Bundle.fromList " ++ show (S.toList s)
instance Arbitrary a => Arbitrary (DV.Vector a) where
@@ -34,10 +35,16 @@ instance (Arbitrary a, DVS.Storable a) => Arbitrary (DVS.Vector a) where
instance (CoArbitrary a, DVS.Storable a) => CoArbitrary (DVS.Vector a) where
coarbitrary = coarbitrary . DVS.toList
-instance Arbitrary a => Arbitrary (S.Stream a) where
+instance (Arbitrary a, DVU.Unbox a) => Arbitrary (DVU.Vector a) where
+ arbitrary = fmap DVU.fromList arbitrary
+
+instance (CoArbitrary a, DVU.Unbox a) => CoArbitrary (DVU.Vector a) where
+ coarbitrary = coarbitrary . DVU.toList
+
+instance Arbitrary a => Arbitrary (S.Bundle v a) where
arbitrary = fmap S.fromList arbitrary
-instance CoArbitrary a => CoArbitrary (S.Stream a) where
+instance CoArbitrary a => CoArbitrary (S.Bundle v a) where
coarbitrary = coarbitrary . S.toList
class (Testable (EqTest a), Conclusion (EqTest a)) => TestData a where
@@ -48,12 +55,12 @@ class (Testable (EqTest a), Conclusion (EqTest a)) => TestData a where
type EqTest a
equal :: a -> a -> EqTest a
-instance Eq a => TestData (S.Stream a) where
- type Model (S.Stream a) = [a]
+instance Eq a => TestData (S.Bundle v a) where
+ type Model (S.Bundle v a) = [a]
model = S.toList
unmodel = S.fromList
- type EqTest (S.Stream a) = Property
+ type EqTest (S.Bundle v a) = Property
equal x y = property (x == y)
instance Eq a => TestData (DV.Vector a) where
@@ -80,6 +87,14 @@ instance (Eq a, DVS.Storable a) => TestData (DVS.Vector a) where
type EqTest (DVS.Vector a) = Property
equal x y = property (x == y)
+instance (Eq a, DVU.Unbox a) => TestData (DVU.Vector a) where
+ type Model (DVU.Vector a) = [a]
+ model = DVU.toList
+ unmodel = DVU.fromList
+
+ type EqTest (DVU.Vector a) = Property
+ equal x y = property (x == y)
+
#define id_TestData(ty) \
instance TestData ty where { \
type Model ty = ty; \
@@ -89,6 +104,7 @@ instance TestData ty where { \
type EqTest ty = Property; \
equal x y = property (x == y) }
+id_TestData(())
id_TestData(Bool)
id_TestData(Int)
id_TestData(Float)