massiv-serialise 1.0.0.1 → 1.0.0.2
raw patch · 10 files changed
+174/−124 lines, 10 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- massiv-serialise.cabal +6/−3
- tests/Common.hs +80/−1
- tests/Main.hs +15/−3
- tests/Spec.hs +0/−1
- tests/Test/Massiv/Serialise/BoxedSpec.hs +14/−0
- tests/Test/Massiv/Serialise/CoreSpec.hs +21/−0
- tests/Test/Massiv/Serialise/PrimitiveSpec.hs +13/−0
- tests/Test/Massiv/Serialise/StorableSpec.hs +14/−0
- tests/Test/Massiv/Serialise/UnboxedSpec.hs +11/−0
- tests/Test/Massiv/SerialiseSpec.hs +0/−116
massiv-serialise.cabal view
@@ -1,5 +1,5 @@ name: massiv-serialise-version: 1.0.0.1+version: 1.0.0.2 synopsis: Compatibility of 'massiv' with 'serialise' description: Orphan 'Serialise' class instances from <https://hackage.haskell.org/package/serialise serialise> package that allow serialization of arrays defined in <https://hackage.haskell.org/package/massiv massiv> package homepage: https://github.com/lehins/massiv-compat@@ -44,8 +44,11 @@ hs-source-dirs: tests main-is: Main.hs other-modules: Common- , Test.Massiv.SerialiseSpec- , Spec+ , Test.Massiv.Serialise.CoreSpec+ , Test.Massiv.Serialise.BoxedSpec+ , Test.Massiv.Serialise.PrimitiveSpec+ , Test.Massiv.Serialise.StorableSpec+ , Test.Massiv.Serialise.UnboxedSpec build-tool-depends: hspec-discover:hspec-discover build-depends: base >= 4.8 && < 5 , massiv-serialise
tests/Common.hs view
@@ -1,6 +1,85 @@+{-# LANGUAGE AllowAmbiguousTypes #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeApplications #-} module Common ( module X+ , roundtrip+ , roundtripArray+ , roundtripArraySpec+ , roundtripArraysSpec ) where-+import Data.Massiv.Array+import Codec.Serialise as X+import Data.Typeable+import Massiv.Serialise as X import Test.Hspec as X+import Test.Hspec.QuickCheck as X+import Test.Massiv.Core import Test.QuickCheck as X++roundtrip :: (Eq a, Show a, Serialise a) => a -> Property+roundtrip val = deserialise (serialise val) === val+++roundtripArray ::+ forall r ix e.+ ( Load r ix e+ , Serialise (Array r ix e)+ , Eq (Array r ix e)+ , Show (Array r ix e)+ )+ => Array r ix e+ -> Property+roundtripArray arr =+ let arr' = deserialise (serialise arr)+ in (arr' === arr) .&&. (getComp arr' === getComp arr)++roundtripArraySpec ::+ forall r ix e.+ ( Eq (Array r ix e)+ , Show (Array r ix e)+ , Typeable e+ , Arbitrary ix+ , Load r ix e+ , Arbitrary e+ , Serialise (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)+ , Serialise (Array r Ix1 e)+ , Load r Ix1 e+ , Eq (Array r Ix2 e)+ , Show (Array r Ix2 e)+ , Serialise (Array r Ix2 e)+ , Load r Ix2 e+ , Eq (Array r Ix3 e)+ , Show (Array r Ix3 e)+ , Serialise (Array r Ix3 e)+ , Load r Ix3 e+ , Eq (Array r Ix4 e)+ , Show (Array r Ix4 e)+ , Load r Ix4 e+ , Serialise (Array r Ix4 e)+ , Eq (Array r Ix5 e)+ , Show (Array r Ix5 e)+ , Serialise (Array r Ix5 e)+ , Load r Ix5 e+ , Typeable e+ , Arbitrary 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.Serialise.BoxedSpec as Boxed (spec)+import qualified Test.Massiv.Serialise.CoreSpec as Core (spec)+import qualified Test.Massiv.Serialise.PrimitiveSpec as Primitive (spec)+import qualified Test.Massiv.Serialise.StorableSpec as Storable (spec)+import qualified Test.Massiv.Serialise.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/Serialise/BoxedSpec.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE TypeApplications #-}+module Test.Massiv.Serialise.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/Serialise/CoreSpec.hs view
@@ -0,0 +1,21 @@+{-# LANGUAGE TypeApplications #-}+module Test.Massiv.Serialise.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/Serialise/PrimitiveSpec.hs view
@@ -0,0 +1,13 @@+{-# LANGUAGE TypeApplications #-}+module Test.Massiv.Serialise.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/Serialise/StorableSpec.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE TypeApplications #-}+module Test.Massiv.Serialise.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/Serialise/UnboxedSpec.hs view
@@ -0,0 +1,11 @@+{-# LANGUAGE TypeApplications #-}+module Test.Massiv.Serialise.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/SerialiseSpec.hs
@@ -1,116 +0,0 @@-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TypeApplications #-}-{-# LANGUAGE AllowAmbiguousTypes #-}--module Test.Massiv.SerialiseSpec (spec) where--import Codec.Serialise-import Common-import Massiv.Serialise ()-import Test.Massiv.Core-import Data.Massiv.Array-import Data.Word--roundtrip :: (Eq a, Show a, Serialise a) => a -> Property-roundtrip val = deserialise (serialise val) === val--roundtripArray ::- forall r ix e.- ( Load r ix e- , Serialise (Array r ix e)- , Eq (Array r ix e)- , Show (Array r ix e)- )- => Array r ix e- -> Property-roundtripArray arr =- let arr' = deserialise (serialise arr)- in (arr' === arr) .&&. (getComp arr' === getComp arr)--roundtripArraySpec ::- forall r ix e.- ( Eq (Array r ix e)- , Show (Array r ix e)- , Typeable e- , Arbitrary ix- , Load r ix e- , Arbitrary e- , Serialise (Array r ix e)- )- => Spec-roundtripArraySpec =- prop (showsType @(Array r ix e) "") $ roundtripArray @r @ix @e--spec :: Spec-spec = do- describe "Serialise" $ 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 @Word8- roundtripArraySpec @P @Ix2 @Word8- roundtripArraySpec @P @Ix3 @Word8- roundtripArraySpec @P @Ix4 @Word8- roundtripArraySpec @P @Ix5 @Word8- roundtripArraySpec @P @Ix1 @Word16- roundtripArraySpec @P @Ix2 @Word16- roundtripArraySpec @P @Ix3 @Word16- roundtripArraySpec @P @Ix4 @Word16- roundtripArraySpec @P @Ix5 @Word16- roundtripArraySpec @P @Ix1 @Word32- roundtripArraySpec @P @Ix2 @Word32- roundtripArraySpec @P @Ix3 @Word32- roundtripArraySpec @P @Ix4 @Word32- roundtripArraySpec @P @Ix5 @Word32- 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 @Word- roundtripArraySpec @U @Ix2 @Word- roundtripArraySpec @U @Ix3 @Word- roundtripArraySpec @U @Ix4 @Word- roundtripArraySpec @U @Ix5 @Word- describe "S" $ do- 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