safecopy-store 0.9.4 → 0.9.5
raw patch · 3 files changed
+49/−4 lines, 3 filesdep +tasty-hunitdep ~vectorPVP ok
version bump matches the API change (PVP)
Dependencies added: tasty-hunit
Dependency ranges changed: vector
API changes (from Hackage documentation)
Files
- CHANGELOG.md +5/−0
- safecopy-store.cabal +3/−3
- test/instances.hs +41/−1
CHANGELOG.md view
@@ -1,3 +1,8 @@+0.9.5+=====++ - push vector bounds + 0.9.4 =====
safecopy-store.cabal view
@@ -3,7 +3,7 @@ -- http://www.haskell.org/cabal/release/cabal-latest/doc/users-guide/authors.html#pkg-descr. -- The name of the package. Name: safecopy-store-Version: 0.9.4+Version: 0.9.5 Synopsis: Binary serialization with version control. Description: Fork of safecopy that uses store instead of cereal. Homepage: https://github.com/NCrashed/safecopy@@ -39,7 +39,7 @@ template-haskell < 2.12, text < 1.3, time < 1.7,- vector >= 0.10 && < 0.12+ vector >= 0.10 && < 0.13 -- Modules not exported by this package. Other-modules: Data.SafeCopy.Store.Instances, Data.SafeCopy.Store.SafeCopy,@@ -64,4 +64,4 @@ GHC-Options: -Wall -threaded -rtsopts -with-rtsopts=-N Build-depends: base, store, template-haskell, safecopy-store, containers, time, array, vector, lens >= 4.7 && < 5.0,- lens-action, tasty, tasty-quickcheck, quickcheck-instances, QuickCheck+ lens-action, tasty, tasty-quickcheck, quickcheck-instances, QuickCheck, tasty-hunit
test/instances.hs view
@@ -2,6 +2,7 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TypeFamilies #-} {-# OPTIONS_GHC -fno-warn-orphans #-} @@ -20,7 +21,7 @@ import Data.Fixed (Fixed, E1) import Data.List import Data.SafeCopy.Store-import Data.Store (decodeWith)+import Data.Store (decodeWith, decodeExWith) import Data.Time (ZonedTime(..)) import Data.Tree (Tree) import Language.Haskell.TH@@ -28,6 +29,7 @@ import Test.QuickCheck.Instances () import Test.Tasty import Test.Tasty.QuickCheck hiding (Fixed, (===))+import Test.Tasty.HUnit #if ! MIN_VERSION_QuickCheck(2,9,0) instance (Arbitrary a, Arbitrary b, Arbitrary c, Arbitrary d, Arbitrary e, Arbitrary f) =>@@ -166,7 +168,45 @@ [d| inversions :: [TestTree] inversions = $(props included) ++ $(props exclusive) |] +data AV0 = AV0 Int deriving (Eq, Show)+deriveSafeCopy 1 'base ''AV0++data AV1 = AV1 Int Int deriving (Eq, Show)+deriveSafeCopy 2 'extension ''AV1++instance Migrate AV1 where+ type MigrateFrom AV1 = AV0+ migrate (AV0 n) = AV1 n 0++data BV0 = BV0 {+ bfield1 :: Int+} deriving (Eq, Show)+deriveSafeCopy 1 'base ''BV0++data BV1 = BV1 {+ bfield2 :: Int+, bfield3 :: Int+} deriving (Eq, Show)+deriveSafeCopy 2 'extension ''BV1++instance Migrate BV1 where+ type MigrateFrom BV1 = BV0+ migrate (BV0 n) = BV1 n 0++migrationTest :: [TestTree]+migrationTest = [+ testCase "Extension test" $ let+ bs = runEncode $ safePut $ AV0 42+ v2 = decodeExWith safeGet bs+ in v2 @?= AV1 42 0+ , testCase "Extension+rename test" $ let+ bs = runEncode $ safePut $ BV0 42+ v2 = decodeExWith safeGet bs+ in v2 @?= BV1 42 0+ ]+ main :: IO () main = defaultMain $ testGroup "SafeCopy instances" [ testGroup "decode is the inverse of encode" inversions+ , testGroup "can decode with migration" migrationTest ]