vector-binary-instances 0.2.3.0 → 0.2.3.1
raw patch · 3 files changed
+36/−2 lines, 3 filesdep +tastydep +tasty-quickcheckdep ~basedep ~binarydep ~vector
Dependencies added: tasty, tasty-quickcheck
Dependency ranges changed: base, binary, vector
Files
- Data/Vector/Binary.hs +1/−1
- test/Main.hs +24/−0
- vector-binary-instances.cabal +11/−1
Data/Vector/Binary.hs view
@@ -93,7 +93,7 @@ v <- return $ unsafePerformIO $ GM.unsafeNew n let go 0 = return () go i = do x <- getA- () <- return $ unsafePerformIO $ GM.unsafeWrite v (i-1) x+ () <- return $ unsafePerformIO $ GM.unsafeWrite v (n-i) x go (i-1) () <- go n return $ unsafePerformIO $ G.unsafeFreeze v
+ test/Main.hs view
@@ -0,0 +1,24 @@+{-# LANGUAGE ScopedTypeVariables #-}++import Test.Tasty+import Test.Tasty.QuickCheck+import Data.Binary+import Data.Vector.Binary+import qualified Data.Vector as V+import qualified Data.Vector.Generic as VG+import qualified Data.Vector.Unboxed as VU+import qualified Data.Vector.Storable as VS++roundTrip :: forall v a. (Eq (v a), Binary (v a), VG.Vector v a)+ => v a -> Property+roundTrip v =+ let v' = decode $ encode v :: v a+ in property $ v' == v++main = defaultMain $ testGroup "Vector Binary instances"+ [ testProperty "Unboxed" $ roundTrip $ VU.enumFromTo z 100+ , testProperty "Storable" $ roundTrip $ VS.enumFromTo z 100+ , testProperty "Boxed" $ roundTrip $ V.enumFromTo z 100+ ]+ where+ z = 0 :: Int
vector-binary-instances.cabal view
@@ -1,5 +1,5 @@ Name: vector-binary-instances-Version: 0.2.3.0+Version: 0.2.3.1 Synopsis: Instances of Data.Binary and Data.Serialize for vector Description: Instances for Binary for the types defined in the vector package,@@ -65,6 +65,16 @@ criterion hs-source-dirs: benchmarks +Test-Suite tests+ Type: exitcode-stdio-1.0+ Main-is: test/Main.hs+ Build-depends:+ base,+ vector-binary-instances,+ vector,+ binary,+ tasty,+ tasty-quickcheck source-repository head type: git