quickcheck-special 0.1.0.2 → 0.1.0.3
raw patch · 2 files changed
+7/−37 lines, 2 filesdep +ieee754PVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: ieee754
API changes (from Hackage documentation)
- Test.QuickCheck.Special: instance Test.QuickCheck.Special.FloatIEEE GHC.Types.Double
- Test.QuickCheck.Special: instance Test.QuickCheck.Special.FloatIEEE GHC.Types.Float
Files
quickcheck-special.cabal view
@@ -3,7 +3,7 @@ -- see: https://github.com/sol/hpack name: quickcheck-special-version: 0.1.0.2+version: 0.1.0.3 synopsis: Edge cases and special values for QuickCheck Arbitrary instances description: The standard Arbitrary instances of QuickCheck don't generate special values. This is fixed by this package which provides the newtype Special with an Arbitrary instance. The special values are given by the SpecialValues typeclass. category: Testing@@ -31,7 +31,8 @@ , bytestring >= 0.9 && < 0.11 , QuickCheck >= 2.1 && < 2.10 , scientific >= 0.2 && < 0.4- , text >= 0.7 && < 1.3+ , text >= 0.7 && < 1.3+ , ieee754 >= 0.8 && < 0.9 if impl(ghc < 7.10) build-depends: nats >= 1
src/Test/QuickCheck/Special.hs view
@@ -23,6 +23,7 @@ import Data.Int import Data.Word import Numeric.Natural (Natural)+import Numeric.IEEE import Test.QuickCheck import qualified Data.ByteString as BS import qualified Data.ByteString.Lazy as BL@@ -99,32 +100,6 @@ instance (SpecialValues a, SpecialValues b) => SpecialValues (a, b) where specialValues = zip specialValues specialValues -class RealFloat a => FloatIEEE a where- nan :: a- infinity :: a- epsilon :: a- minDenormal :: a- minNormal :: a- maxFinite :: a---- echo | gcc -E -dM - | grep _FLT_-instance FloatIEEE Float where- nan = 0/0- infinity = 1/0- epsilon = 1.19209289550781250000e-7- minDenormal = 1.40129846432481707092e-45- minNormal = 1.17549435082228750797e-38- maxFinite = 3.40282346638528859812e+38---- echo | gcc -E -dM - | grep _DBL_-instance FloatIEEE Double where- nan = 0/0- infinity = 1/0- epsilon = 2.22044604925031308085e-16- minDenormal = 4.94065645841246544177e-324- minNormal = 2.22507385850720138309e-308- maxFinite = 1.79769313486231570815e+308- instance (Arbitrary a, SpecialValues a) => Arbitrary (Special a) where shrink = fmap Special . shrink . getSpecial arbitrary = fmap Special $ frequency $ list specialValues@@ -133,15 +108,9 @@ instance CoArbitrary a => CoArbitrary (Special a) where coarbitrary = coarbitrary . getSpecial -specialIEEE :: FloatIEEE a => [a]-specialIEEE = [0, 1, -1- , nan- , epsilon, -epsilon- , infinity, -infinity- , minDenormal, -minDenormal- , minNormal, -minNormal- , maxFinite, -maxFinite- ]+specialIEEE :: IEEE a => [a]+specialIEEE = list ++ map negate list+ where list = [nan, 0, 1, epsilon, infinity, minDenormal, minNormal, maxFinite] specialInt :: (Num a, Bounded a) => [a] specialInt = [0, 1, -1, minBound, maxBound, minBound + 1, maxBound - 1]