arithmoi 0.5.0.0 → 0.5.0.1
raw patch · 6 files changed
+54/−61 lines, 6 filesdep ~QuickCheckdep ~tasty-quickcheckPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: QuickCheck, tasty-quickcheck
API changes (from Hackage documentation)
Files
- Changes +3/−0
- arithmoi.cabal +4/−4
- test-suite/Math/NumberTheory/ModuliTests.hs +14/−15
- test-suite/Math/NumberTheory/TestUtils.hs +2/−3
- test-suite/Math/NumberTheory/TestUtils/Compose.hs +0/−39
- test-suite/Math/NumberTheory/TestUtils/MyCompose.hs +31/−0
Changes view
@@ -1,3 +1,6 @@+0.5.0.1:+ Switch to QuickCheck 2.10.+ 0.5.0.0: This release supports GHC 7.8, 7.10 and 8.0. GHC 7.6 is no longer supported.
arithmoi.cabal view
@@ -1,5 +1,5 @@ name : arithmoi-version : 0.5.0.0+version : 0.5.0.1 cabal-version : >= 1.10 author : Daniel Fischer copyright : (c) 2011 Daniel Fischer, 2016-2017 Andrew Lelechenko, Carter Schonwald@@ -128,9 +128,9 @@ , arithmoi >= 0.5 && < 0.6 , tasty >= 0.10 && < 0.12 , tasty-smallcheck >= 0.8 && < 0.9- , tasty-quickcheck >= 0.8 && < 0.9+ , tasty-quickcheck >= 0.9 && < 0.10 , tasty-hunit >= 0.9 && < 0.10- , QuickCheck >= 2.7.6 && < 2.10+ , QuickCheck >= 2.10 && < 2.11 , smallcheck >= 1.1 && < 1.2 , transformers >= 0.5 , integer-gmp < 1.1@@ -158,6 +158,6 @@ , Math.NumberTheory.Primes.TestingTests , Math.NumberTheory.TestUtils , Math.NumberTheory.TestUtils.Wrappers- , Math.NumberTheory.TestUtils.Compose+ , Math.NumberTheory.TestUtils.MyCompose , Math.NumberTheory.UniqueFactorisationTests , Math.NumberTheory.ZetaTests
test-suite/Math/NumberTheory/ModuliTests.hs view
@@ -23,7 +23,6 @@ import Data.Bits import Data.List (tails, nub) import Data.Maybe-import Data.Functor.Compose import Math.NumberTheory.Moduli import Math.NumberTheory.TestUtils@@ -32,42 +31,42 @@ unwrapPP (Prime p, Power e) = (p, e) -- | Check that 'jacobi' matches 'jacobi''.-jacobiProperty1 :: (Integral a, Bits a) => AnySign a -> (Compose Positive Odd) a -> Bool-jacobiProperty1 (AnySign a) (Compose (Positive (Odd n))) = n == 1 && j == 1 || n > 1 && j == j'+jacobiProperty1 :: (Integral a, Bits a) => AnySign a -> (MyCompose Positive Odd) a -> Bool+jacobiProperty1 (AnySign a) (MyCompose (Positive (Odd n))) = n == 1 && j == 1 || n > 1 && j == j' where j = jacobi a n j' = jacobi' a n -- https://en.wikipedia.org/wiki/Jacobi_symbol#Properties, item 2-jacobiProperty2 :: (Integral a, Bits a) => AnySign a -> (Compose Positive Odd) a -> Bool-jacobiProperty2 (AnySign a) (Compose (Positive (Odd n)))+jacobiProperty2 :: (Integral a, Bits a) => AnySign a -> (MyCompose Positive Odd) a -> Bool+jacobiProperty2 (AnySign a) (MyCompose (Positive (Odd n))) = a + n < a -- check overflow || jacobi a n == jacobi (a + n) n -- https://en.wikipedia.org/wiki/Jacobi_symbol#Properties, item 3-jacobiProperty3 :: (Integral a, Bits a) => AnySign a -> (Compose Positive Odd) a -> Bool-jacobiProperty3 (AnySign a) (Compose (Positive (Odd n))) = j == 0 && g /= 1 || abs j == 1 && g == 1+jacobiProperty3 :: (Integral a, Bits a) => AnySign a -> (MyCompose Positive Odd) a -> Bool+jacobiProperty3 (AnySign a) (MyCompose (Positive (Odd n))) = j == 0 && g /= 1 || abs j == 1 && g == 1 where j = jacobi a n g = gcd a n -- https://en.wikipedia.org/wiki/Jacobi_symbol#Properties, item 4-jacobiProperty4 :: (Integral a, Bits a) => AnySign a -> AnySign a -> (Compose Positive Odd) a -> Bool-jacobiProperty4 (AnySign a) (AnySign b) (Compose (Positive (Odd n))) = jacobi (a * b) n == jacobi a n * jacobi b n+jacobiProperty4 :: (Integral a, Bits a) => AnySign a -> AnySign a -> (MyCompose Positive Odd) a -> Bool+jacobiProperty4 (AnySign a) (AnySign b) (MyCompose (Positive (Odd n))) = jacobi (a * b) n == jacobi a n * jacobi b n -jacobiProperty4_Integer :: AnySign Integer -> AnySign Integer -> (Compose Positive Odd) Integer -> Bool+jacobiProperty4_Integer :: AnySign Integer -> AnySign Integer -> (MyCompose Positive Odd) Integer -> Bool jacobiProperty4_Integer = jacobiProperty4 -- https://en.wikipedia.org/wiki/Jacobi_symbol#Properties, item 5-jacobiProperty5 :: (Integral a, Bits a) => AnySign a -> (Compose Positive Odd) a -> (Compose Positive Odd) a -> Bool-jacobiProperty5 (AnySign a) (Compose (Positive (Odd m))) (Compose (Positive (Odd n))) = jacobi a (m * n) == jacobi a m * jacobi a n+jacobiProperty5 :: (Integral a, Bits a) => AnySign a -> (MyCompose Positive Odd) a -> (MyCompose Positive Odd) a -> Bool+jacobiProperty5 (AnySign a) (MyCompose (Positive (Odd m))) (MyCompose (Positive (Odd n))) = jacobi a (m * n) == jacobi a m * jacobi a n -jacobiProperty5_Integer :: AnySign Integer -> (Compose Positive Odd) Integer -> (Compose Positive Odd) Integer -> Bool+jacobiProperty5_Integer :: AnySign Integer -> (MyCompose Positive Odd) Integer -> (MyCompose Positive Odd) Integer -> Bool jacobiProperty5_Integer = jacobiProperty5 -- https://en.wikipedia.org/wiki/Jacobi_symbol#Properties, item 6-jacobiProperty6 :: (Integral a, Bits a) => (Compose Positive Odd) a -> (Compose Positive Odd) a -> Bool-jacobiProperty6 (Compose (Positive (Odd m))) (Compose (Positive (Odd n))) = gcd m n /= 1 || jacobi m n * jacobi n m == (if m `mod` 4 == 1 || n `mod` 4 == 1 then 1 else -1)+jacobiProperty6 :: (Integral a, Bits a) => (MyCompose Positive Odd) a -> (MyCompose Positive Odd) a -> Bool+jacobiProperty6 (MyCompose (Positive (Odd m))) (MyCompose (Positive (Odd n))) = gcd m n /= 1 || jacobi m n * jacobi n m == (if m `mod` 4 == 1 || n `mod` 4 == 1 then 1 else -1) -- | Check that 'invertMod' inverts numbers modulo. invertModProperty :: AnySign Integer -> Positive Integer -> Bool
test-suite/Math/NumberTheory/TestUtils.hs view
@@ -33,6 +33,7 @@ module Math.NumberTheory.TestUtils ( module Math.NumberTheory.TestUtils.Wrappers+ , module Math.NumberTheory.TestUtils.MyCompose , module Test.SmallCheck.Series , Large(..) , testIntegralProperty@@ -58,7 +59,7 @@ import Math.NumberTheory.GaussianIntegers (GaussianInteger(..)) -import Math.NumberTheory.TestUtils.Compose ()+import Math.NumberTheory.TestUtils.MyCompose import Math.NumberTheory.TestUtils.Wrappers instance Monad m => Serial m Word where@@ -67,11 +68,9 @@ where nats = generate $ \d -> if d > 0 then [1 .. fromInteger (toInteger d)] else empty -#if !(MIN_VERSION_base(4,8,0)) && !(MIN_VERSION_QuickCheck(2,9,0)) instance Arbitrary Natural where arbitrary = fromInteger <$> (arbitrary `suchThat` (>= 0)) shrink = map fromInteger . filter (>= 0) . shrink . toInteger-#endif instance Monad m => Serial m Natural where series =
− test-suite/Math/NumberTheory/TestUtils/Compose.hs
@@ -1,39 +0,0 @@--- |--- Module: Math.NumberTheory.TestUtils.Compose--- Copyright: (c) 2016 Andrew Lelechenko--- Licence: MIT--- Maintainer: Andrew Lelechenko <andrew.lelechenko@gmail.com>--- Stability: Provisional--- Portability: Non-portable (GHC extensions)------ Utils to test Math.NumberTheory-----{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE GeneralizedNewtypeDeriving #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE StandaloneDeriving #-}-{-# LANGUAGE UndecidableInstances #-}--{-# OPTIONS_GHC -fno-warn-orphans #-}--module Math.NumberTheory.TestUtils.Compose where--import Data.Functor.Classes-import Data.Functor.Compose--import Test.Tasty.QuickCheck (Arbitrary)-import Test.SmallCheck.Series (Serial)--deriving instance Num (f (g a)) => Num (Compose f g a)-deriving instance Enum (f (g a)) => Enum (Compose f g a)-deriving instance Bounded (f (g a)) => Bounded (Compose f g a)--deriving instance (Ord1 f, Ord1 g, Ord a, Real (f (g a))) => Real (Compose f g a)-deriving instance (Ord1 f, Ord1 g, Ord a, Integral (f (g a))) => Integral (Compose f g a)--deriving instance Arbitrary (f (g a)) => Arbitrary (Compose f g a)--instance (Monad m, Serial m (f (g a))) => Serial m (Compose f g a)
+ test-suite/Math/NumberTheory/TestUtils/MyCompose.hs view
@@ -0,0 +1,31 @@+-- |+-- Module: Math.NumberTheory.TestUtils.MyCompose+-- Copyright: (c) 2016-2017 Andrew Lelechenko+-- Licence: MIT+-- Maintainer: Andrew Lelechenko <andrew.lelechenko@gmail.com>+-- Stability: Provisional+-- Portability: Non-portable (GHC extensions)+--+-- Utils to test Math.NumberTheory+--++{-# LANGUAGE DeriveFunctor #-}+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE MultiParamTypeClasses #-}++module Math.NumberTheory.TestUtils.MyCompose+ ( MyCompose(..)+ ) where++import GHC.Generics (Generic)++import Test.QuickCheck (Arbitrary)+import Test.SmallCheck.Series (Serial)++newtype MyCompose f g a = MyCompose { getMyCompose :: f (g a) }+ deriving (Eq, Ord, Show, Functor, Num, Enum, Bounded, Real, Integral, Arbitrary, Generic)++instance (Monad m, Serial m (f (g a))) => Serial m (MyCompose f g a)