genvalidity 0.10.0.2 → 0.11.0.0
raw patch · 3 files changed
+58/−30 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.GenValidity.Utils: genUncheckedInt :: (Int# -> a) -> Gen a
+ Data.GenValidity.Utils: genUncheckedWord :: (Word# -> a) -> Gen a
+ Data.GenValidity.Utils: shrinkUncheckedInt :: (Int -> a) -> (a -> Int) -> a -> [a]
+ Data.GenValidity.Utils: shrinkUncheckedWord :: (Word -> a) -> (a -> Word) -> a -> [a]
Files
- genvalidity.cabal +3/−3
- src/Data/GenValidity.hs +31/−27
- src/Data/GenValidity/Utils.hs +24/−0
genvalidity.cabal view
@@ -1,13 +1,13 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.31.2.+-- This file has been generated from package.yaml by hpack version 0.33.0. -- -- see: https://github.com/sol/hpack ----- hash: 80513e8153ba436dea2585e9c58009687ae95e2cfa57f1e8b341c3d103fd2e85+-- hash: a5dc5e1588ff412e964237d33283651af0936a55506c5f8e6919d2ab901c77ec name: genvalidity-version: 0.10.0.2+version: 0.11.0.0 synopsis: Testing utilities for the validity library description: Note: There are companion instance packages for this library: .
src/Data/GenValidity.hs view
@@ -48,6 +48,7 @@ {-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MagicHash #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE MultiWayIf #-} {-# LANGUAGE TypeOperators #-}@@ -103,11 +104,14 @@ import Data.List.NonEmpty (NonEmpty((:|))) #endif #if MIN_VERSION_base(4,8,0)-import Data.Word (Word8, Word16, Word32, Word64)+import Data.Word (Word64)+import GHC.Word (Word8(..), Word16(..), Word32(..), Word(..)) #else-import Data.Word (Word, Word8, Word16, Word32, Word64)+import Data.Word (Word, Word64)+import GHC.Word (Word8(..), Word16(..), Word32(..), Word(..)) #endif-import Data.Int (Int8, Int16, Int32, Int64)+import Data.Int (Int64)+import GHC.Int (Int8(..), Int16(..), Int32(..), Int(..)) import Data.Char (chr) import Data.Ratio ((%)) import GHC.Generics@@ -591,28 +595,28 @@ shrinkValid = shrinkUnchecked instance GenUnchecked Int8 where- genUnchecked = genIntX- shrinkUnchecked = shrink+ genUnchecked = genUncheckedInt (I8#)+ shrinkUnchecked = shrinkUncheckedInt (\(I# i#) -> I8# i#) (\(I8# i#) -> I# i#) instance GenValid Int8 where- genValid = genUnchecked- shrinkValid = shrinkUnchecked+ genValid = genIntX+ shrinkValid = shrink instance GenUnchecked Int16 where- genUnchecked = genIntX- shrinkUnchecked = shrink+ genUnchecked = genUncheckedInt (I16#)+ shrinkUnchecked = shrinkUncheckedInt (\(I# i#) -> I16# i#) (\(I16# i#) -> I# i#) instance GenValid Int16 where- genValid = genUnchecked- shrinkValid = shrinkUnchecked+ genValid = genIntX+ shrinkValid = shrink instance GenUnchecked Int32 where- genUnchecked = genIntX- shrinkUnchecked = shrink+ genUnchecked = genUncheckedInt (I32#)+ shrinkUnchecked = shrinkUncheckedInt (\(I# i#) -> I32# i#) (\(I32# i#) -> I# i#) instance GenValid Int32 where- genValid = genUnchecked- shrinkValid = shrinkUnchecked+ genValid = genIntX+ shrinkValid = shrink instance GenUnchecked Int64 where genUnchecked = genIntX@@ -631,28 +635,28 @@ shrinkValid = shrinkUnchecked instance GenUnchecked Word8 where- genUnchecked = genWordX- shrinkUnchecked = shrink+ genUnchecked = genUncheckedWord (W8#)+ shrinkUnchecked = shrinkUncheckedWord (\(W# w#) -> W8# w#) (\(W8# w#) -> W# w#) instance GenValid Word8 where- genValid = genUnchecked- shrinkValid = shrinkUnchecked+ genValid = genWordX+ shrinkValid = shrink instance GenUnchecked Word16 where- genUnchecked = genWordX- shrinkUnchecked = shrink+ genUnchecked = genUncheckedWord (W16#)+ shrinkUnchecked = shrinkUncheckedWord (\(W# w#) -> W16# w#) (\(W16# w#) -> W# w#) instance GenValid Word16 where- genValid = genUnchecked- shrinkValid = shrinkUnchecked+ genValid = genWordX+ shrinkValid = shrink instance GenUnchecked Word32 where- genUnchecked = genWordX- shrinkUnchecked = shrink+ genUnchecked = genUncheckedWord (W32#)+ shrinkUnchecked = shrinkUncheckedWord (\(W# w#) -> W32# w#) (\(W32# w#) -> W# w#) instance GenValid Word32 where- genValid = genUnchecked- shrinkValid = shrinkUnchecked+ genValid = genWordX+ shrinkValid = shrink instance GenUnchecked Word64 where genUnchecked = genWordX
src/Data/GenValidity/Utils.hs view
@@ -2,6 +2,7 @@ {-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MagicHash #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE MultiWayIf #-} {-# LANGUAGE ScopedTypeVariables #-}@@ -43,11 +44,18 @@ , genDouble , genFloatX , genInteger+ , genUncheckedInt+ , shrinkUncheckedInt+ , genUncheckedWord+ , shrinkUncheckedWord ) where import Test.QuickCheck hiding (Fixed) import System.Random import GHC.Float+import GHC.Int (Int(..))+import GHC.Word (Word(..))+import GHC.Exts (Word#, Int#) import Data.Ratio #if !MIN_VERSION_QuickCheck(2,8,0) import Data.List (sortBy)@@ -361,3 +369,19 @@ bi <- resize b genInteger ci <- resize c genIntSizedInteger pure $ ai * bi + ci++genUncheckedInt :: (Int# -> a) -> Gen a+genUncheckedInt func = do+ (I# i#) <- genIntX+ pure $ func i#++shrinkUncheckedInt :: (Int -> a) -> (a -> Int) -> a -> [a]+shrinkUncheckedInt fromInt toInt = fmap fromInt . shrink . toInt++genUncheckedWord :: (Word# -> a) -> Gen a+genUncheckedWord func = do+ (W# w#) <- genWordX+ pure $ func w#++shrinkUncheckedWord :: (Word -> a) -> (a -> Word) -> a -> [a]+shrinkUncheckedWord fromWord toWord = fmap fromWord . shrink . toWord