packages feed

massiv-persist 1.0.0.1 → 1.0.0.2

raw patch · 10 files changed

+183/−131 lines, 10 filesdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

Files

massiv-persist.cabal view
@@ -1,5 +1,5 @@ name:                massiv-persist-version:             1.0.0.1+version:             1.0.0.2 synopsis:            Compatibility of 'massiv' with 'persist' description:         Orphan 'Persist' class instances from <https://hackage.haskell.org/package/persist persist> package that allow serialization of arrays defined in <https://hackage.haskell.org/package/massiv massiv> package homepage:            https://github.com/lehins/massiv-compat@@ -45,8 +45,11 @@   hs-source-dirs:     tests   main-is:            Main.hs   other-modules:      Common-                    , Test.Massiv.PersistSpec-                    , Spec+                    , Test.Massiv.Persist.CoreSpec+                    , Test.Massiv.Persist.BoxedSpec+                    , Test.Massiv.Persist.PrimitiveSpec+                    , Test.Massiv.Persist.StorableSpec+                    , Test.Massiv.Persist.UnboxedSpec   build-tool-depends: hspec-discover:hspec-discover   build-depends:      base             >= 4.8 && < 5                     , massiv-persist
tests/Common.hs view
@@ -1,6 +1,95 @@+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeApplications #-}+{-# LANGUAGE AllowAmbiguousTypes #-} module Common   ( module X+  , roundtrip+  , roundtripArray+  , roundtripArraySpec+  , roundtripArraysSpec   ) where  import Test.Hspec as X+import Test.Hspec.QuickCheck as X import Test.QuickCheck as X+import Data.Persist as X+import Massiv.Persist as X+import Data.Typeable+import Data.Massiv.Array+import Test.Massiv.Core++roundtrip :: (Eq a, Show a, Persist a) => a -> Property+roundtrip val = either error id (decode (encode val)) === val++roundtripArray ::+     forall r ix e.+     ( Mutable r e+     , Index ix+     , Persist e+     , Persist (Array r ix e)+     , Eq (Array r ix e)+     , Show (Array r ix e)+     )+  => Array r ix e+  -> Property+roundtripArray arr = expectProp $ do+  let arr'' = either error id (runGet getArray (runPut (putArray arr)))+  getComp arr'' `shouldBe` getComp arr+  arr'' `shouldBe` arr+  let arr' = either error id (decode (encode arr))+  getComp arr' `shouldBe` getComp arr+  arr' `shouldBe` arr++roundtripArraySpec ::+     forall r ix e.+     ( Eq (Array r ix e)+     , Show (Array r ix e)+     , Typeable e+     , Arbitrary ix+     , Load r ix e+     , Mutable r e+     , Arbitrary e+     , Persist e+     , Persist (Array r ix e)+     )+  => Spec+roundtripArraySpec =+  prop (showsType @(Array r ix e) "") $ roundtripArray @r @ix @e+++roundtripArraysSpec ::+     forall r e.+     ( Eq (Array r Ix1 e)+     , Show (Array r Ix1 e)+     , Persist (Array r Ix1 e)+     , Load r Ix1 e+     , Eq (Array r Ix2 e)+     , Show (Array r Ix2 e)+     , Persist (Array r Ix2 e)+     , Load r Ix2 e+     , Eq (Array r Ix3 e)+     , Show (Array r Ix3 e)+     , Persist (Array r Ix3 e)+     , Load r Ix3 e+     , Eq (Array r Ix4 e)+     , Show (Array r Ix4 e)+     , Load r Ix4 e+     , Persist (Array r Ix4 e)+     , Eq (Array r Ix5 e)+     , Show (Array r Ix5 e)+     , Persist (Array r Ix5 e)+     , Load r Ix5 e+     , Typeable e+     , Mutable r e+     , Arbitrary e+     , Persist e+     )+  => Spec+roundtripArraysSpec =+  describe (showsType @e "") $ do+    roundtripArraySpec @r @Ix1 @e+    roundtripArraySpec @r @Ix2 @e+    roundtripArraySpec @r @Ix3 @e+    roundtripArraySpec @r @Ix4 @e+    roundtripArraySpec @r @Ix5 @e
tests/Main.hs view
@@ -1,11 +1,23 @@ module Main where -import Spec (spec)-import System.IO (BufferMode (LineBuffering), hSetBuffering, hSetEncoding, stdout, utf8)+import System.IO (BufferMode(LineBuffering), hSetBuffering, hSetEncoding, stdout, utf8) import Test.Hspec+import qualified Test.Massiv.Persist.BoxedSpec as Boxed (spec)+import qualified Test.Massiv.Persist.CoreSpec as Core (spec)+import qualified Test.Massiv.Persist.PrimitiveSpec as Primitive (spec)+import qualified Test.Massiv.Persist.StorableSpec as Storable (spec)+import qualified Test.Massiv.Persist.UnboxedSpec as Unboxed (spec)  main :: IO () main = do   hSetBuffering stdout LineBuffering   hSetEncoding stdout utf8-  hspec spec+  hspec $ do+    describe "Core" $ do+      Core.spec+    describe "Boxed" $ do+      Boxed.spec+    describe "Unboxed" $ do+      Primitive.spec+      Storable.spec+      Unboxed.spec
− tests/Spec.hs
@@ -1,1 +0,0 @@-{-# OPTIONS_GHC -F -pgmF hspec-discover -optF --module-name=Spec #-}
+ tests/Test/Massiv/Persist/BoxedSpec.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE TypeApplications #-}+module Test.Massiv.Persist.BoxedSpec (spec) where++import Common+import Data.Massiv.Array++spec :: Spec+spec = do+  describe "B" $ do+    roundtripArraysSpec @B @Integer+  describe "BN" $ do+    roundtripArraysSpec @BN @Integer+  describe "BL" $ do+    roundtripArraysSpec @BL @Integer
+ tests/Test/Massiv/Persist/CoreSpec.hs view
@@ -0,0 +1,21 @@+{-# LANGUAGE TypeApplications #-}+module Test.Massiv.Persist.CoreSpec (spec) where++import Common+import Data.Massiv.Array++spec :: Spec+spec = do+  describe "Strategy" $ do+    prop "Comp" $ roundtrip @Comp+  describe "Index" $ do+    prop "Ix2" $ roundtrip @Ix2+    prop "Ix3" $ roundtrip @Ix3+    prop "Ix4" $ roundtrip @Ix4+    prop "Ix5" $ roundtrip @Ix5+  describe "Size" $ do+    prop "Sz1" $ roundtrip @Sz1+    prop "Sz2" $ roundtrip @Sz2+    prop "Sz3" $ roundtrip @Sz3+    prop "Sz4" $ roundtrip @Sz4+    prop "Sz5" $ roundtrip @Sz5
+ tests/Test/Massiv/Persist/PrimitiveSpec.hs view
@@ -0,0 +1,13 @@+{-# LANGUAGE TypeApplications #-}+module Test.Massiv.Persist.PrimitiveSpec (spec) where++import Common+import Data.Massiv.Array+import Data.Word++spec :: Spec+spec = do+  describe "P" $ do+    roundtripArraysSpec @P @Word32+    roundtripArraysSpec @P @Word64+    roundtripArraysSpec @P @Word
+ tests/Test/Massiv/Persist/StorableSpec.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE TypeApplications #-}+module Test.Massiv.Persist.StorableSpec (spec) where++import Common+import Data.Massiv.Array+import Data.Word++spec :: Spec+spec =+  describe "S" $ do+    roundtripArraysSpec @S @Bool+    roundtripArraysSpec @S @Word32+    roundtripArraysSpec @S @Word64+    roundtripArraysSpec @S @Word
+ tests/Test/Massiv/Persist/UnboxedSpec.hs view
@@ -0,0 +1,11 @@+{-# LANGUAGE TypeApplications #-}+module Test.Massiv.Persist.UnboxedSpec (spec) where++import Common+import Data.Massiv.Array++spec :: Spec+spec = do+  describe "U" $ do+    roundtripArraysSpec @U @Bool+    roundtripArraysSpec @U @(Int, Word)
− tests/Test/Massiv/PersistSpec.hs
@@ -1,124 +0,0 @@-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TypeApplications #-}-{-# LANGUAGE AllowAmbiguousTypes #-}--module Test.Massiv.PersistSpec (spec) where--import Data.Persist-import Common-import Massiv.Persist-import Test.Massiv.Core-import Data.Massiv.Array-import Data.Word--roundtrip :: (Eq a, Show a, Persist a) => a -> Property-roundtrip val = either error id (decode (encode val)) === val--roundtripArray ::-     forall r ix e.-     ( Mutable r e-     , Index ix-     , Persist e-     , Persist (Array r ix e)-     , Eq (Array r ix e)-     , Show (Array r ix e)-     )-  => Array r ix e-  -> Property-roundtripArray arr = expectProp $ do-  let arr'' = either error id (runGet getArray (runPut (putArray arr)))-  getComp arr'' `shouldBe` getComp arr-  arr'' `shouldBe` arr-  let arr' = either error id (decode (encode arr))-  getComp arr' `shouldBe` getComp arr-  arr' `shouldBe` arr--roundtripArraySpec ::-     forall r ix e.-     ( Eq (Array r ix e)-     , Show (Array r ix e)-     , Typeable e-     , Arbitrary ix-     , Load r ix e-     , Mutable r e-     , Arbitrary e-     , Persist e-     , Persist (Array r ix e)-     )-  => Spec-roundtripArraySpec =-  prop (showsType @(Array r ix e) "") $ roundtripArray @r @ix @e--spec :: Spec-spec = do-  describe "Persist" $ do-    prop "Comp" $ roundtrip @Comp-    describe "Ix" $ do-      prop "Ix2" $ roundtrip @Ix2-      prop "Ix3" $ roundtrip @Ix3-      prop "Ix4" $ roundtrip @Ix4-      prop "Ix5" $ roundtrip @Ix5-    describe "Sz" $ do-      prop "Sz1" $ roundtrip @Sz1-      prop "Sz2" $ roundtrip @Sz2-      prop "Sz3" $ roundtrip @Sz3-      prop "Sz4" $ roundtrip @Sz4-      prop "Sz5" $ roundtrip @Sz5-    describe "Array" $ do-      describe "P" $ do-        roundtripArraySpec @P @Ix1 @Word16-        roundtripArraySpec @P @Ix2 @Word16-        roundtripArraySpec @P @Ix3 @Word16-        roundtripArraySpec @P @Ix4 @Word16-        roundtripArraySpec @P @Ix5 @Word16-        roundtripArraySpec @P @Ix1 @Word64-        roundtripArraySpec @P @Ix2 @Word64-        roundtripArraySpec @P @Ix3 @Word64-        roundtripArraySpec @P @Ix4 @Word64-        roundtripArraySpec @P @Ix5 @Word64-        roundtripArraySpec @P @Ix1 @Word-        roundtripArraySpec @P @Ix2 @Word-        roundtripArraySpec @P @Ix3 @Word-        roundtripArraySpec @P @Ix4 @Word-        roundtripArraySpec @P @Ix5 @Word-      describe "U" $ do-        roundtripArraySpec @U @Ix1 @(Int, Word)-        roundtripArraySpec @U @Ix2 @(Int, Word)-        roundtripArraySpec @U @Ix3 @(Int, Word)-        roundtripArraySpec @U @Ix4 @(Int, Word)-        roundtripArraySpec @U @Ix5 @(Int, Word)-      describe "S" $ do-        roundtripArraySpec @S @Ix1 @Word16-        roundtripArraySpec @S @Ix2 @Word16-        roundtripArraySpec @S @Ix3 @Word16-        roundtripArraySpec @S @Ix4 @Word16-        roundtripArraySpec @S @Ix5 @Word16-        roundtripArraySpec @S @Ix1 @Word64-        roundtripArraySpec @S @Ix2 @Word64-        roundtripArraySpec @S @Ix3 @Word64-        roundtripArraySpec @S @Ix4 @Word64-        roundtripArraySpec @S @Ix5 @Word64-        roundtripArraySpec @S @Ix1 @Word-        roundtripArraySpec @S @Ix2 @Word-        roundtripArraySpec @S @Ix3 @Word-        roundtripArraySpec @S @Ix4 @Word-        roundtripArraySpec @S @Ix5 @Word-      describe "B" $ do-        roundtripArraySpec @B @Ix1 @Integer-        roundtripArraySpec @B @Ix2 @Integer-        roundtripArraySpec @B @Ix3 @Integer-        roundtripArraySpec @B @Ix4 @Integer-        roundtripArraySpec @B @Ix5 @Integer-      describe "BN" $ do-        roundtripArraySpec @BN @Ix1 @Integer-        roundtripArraySpec @BN @Ix2 @Integer-        roundtripArraySpec @BN @Ix3 @Integer-        roundtripArraySpec @BN @Ix4 @Integer-        roundtripArraySpec @BN @Ix5 @Integer-      describe "BL" $ do-        roundtripArraySpec @BL @Ix1 @Integer-        roundtripArraySpec @BL @Ix2 @Integer-        roundtripArraySpec @BL @Ix3 @Integer-        roundtripArraySpec @BL @Ix4 @Integer-        roundtripArraySpec @BL @Ix5 @Integer