packages feed

gray-extended 1.5.1 → 1.5.2

raw patch · 5 files changed

+74/−159 lines, 5 filesdep ~QuickCheckdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: QuickCheck, base

API changes (from Hackage documentation)

Files

LICENSE view
@@ -1,27 +1,30 @@-Copyright (c) 2010-2012, Amy de Buitléir+Copyright Amy de Buitléir (c) 2010-2016+ All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met:+Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met: -* Redistributions of source code must retain the above copyright -  notice, this list of conditions and the following disclaimer.-* Redistributions in binary form must reproduce the above copyright-  notice, this list of conditions and the following disclaimer in the-  documentation and/or other materials provided with the distribution.-* Neither the name of the author nor the names of other contributors-  may be used to endorse or promote products derived from this software-  without specific prior written permission.+    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Amy de Buitléir nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
gray-extended.cabal view
@@ -1,44 +1,41 @@-name:           gray-extended-version:        1.5.1-synopsis:       Gray encoding schemes-description:    Gray codes satisfy the property that two successive values -                differ in only one digit. Usually the term \"Gray code\"-                refers to the Binary Reflected Gray code (BRGC),  but -                non-binary Gray codes have also been discovered.-category:       Math-Homepage:       https://github.com/mhwombat/gray-extended-cabal-version:  >=1.8-build-type:     Simple-author:         Amy de Buitléir-copyright:      (c) Amy de Buitléir 2010-2012-license:        BSD3-stability:      experimental-maintainer:     amy@nualeargais.ie-license-file:   LICENSE--source-repository head-  type:     git-  location: https://github.com/mhwombat/gray-extended.git--source-repository this-  type:     git-  location: https://github.com/mhwombat/gray-extended.git-  tag:      1.5.1+name:                gray-extended+version:             1.5.2+synopsis:            Gray encoding schemes+description:         Gray codes satisfy the property that two successive values +                     differ in only one digit. Usually the term \"Gray code\"+                     refers to the Binary Reflected Gray code (BRGC),  but +                     non-binary Gray codes have also been discovered.+homepage:            https://github.com/mhwombat/gray-extended#readme+bug-reports:         https://github.com/mhwombat/gray-extended/issues+license:             BSD3+license-file:        LICENSE+author:              Amy de Buitléir+maintainer:          amy@nualeargais.ie+copyright:           (c) Amy de Buitléir 2010-2016+category:            Math+build-type:          Simple+-- extra-source-files:+cabal-version:       >=1.10  library-  hs-source-dirs:  src-  build-depends:   base ==4.*-  ghc-options:     -Wall-  exposed-modules: Codec.Gray+  hs-source-dirs:      src+  exposed-modules:     Codec.Gray+  ghc-options:         -Wall+  build-depends:       base >= 4.7 && < 5+  default-language:    Haskell2010 -test-suite gray-extended-tests-  type:            exitcode-stdio-1.0-  build-depends:   base ==4.*,-                   test-framework-quickcheck2 == 0.3.*,-                   QuickCheck == 2.7.*,-                   test-framework == 0.8.*,-                   gray-extended-  hs-source-dirs:  test-  ghc-options:     -Wall -Werror -rtsopts-  main-is:         Main.hs-  other-modules:   Codec.GrayQC+test-suite gray-extended-test+  type:                exitcode-stdio-1.0+  hs-source-dirs:      test+  main-is:             TestMain.hs+  build-depends:       base,+                       gray-extended,+                       test-framework ==0.8.*,+                       test-framework-quickcheck2 ==0.3.*,+                       QuickCheck ==2.7.* || ==2.8.* || ==2.9.*+  ghc-options:         -threaded -rtsopts -with-rtsopts=-N -Wall+  default-language:    Haskell2010++source-repository head+  type:     git+  location: https://github.com/mhwombat/gray-extended
− test/Codec/GrayQC.hs
@@ -1,85 +0,0 @@-module Codec.GrayQC-  (-    test-  ) where--import Codec.Gray-import Data.List (nub)-import Data.Word (Word8)-import Test.Framework as TF (Test, testGroup)-import Test.Framework.Providers.QuickCheck2 (testProperty)-import Test.QuickCheck ((==>), Property, Gen, Arbitrary, arbitrary, choose, -  property, sized)--prop_successive_values_differ_in_one_place1 :: Int -> Property-prop_successive_values_differ_in_one_place1 k = k > 0 ==>-  nub (diffCounts xs) == [1]-    where xs = grayCodes k'-          k' = min 10 k -- avoid long tests--data TestParms = TestParms String Int deriving Show--sizedTestParms :: Int -> Gen TestParms-sizedTestParms n = do-  let n' = 2 + (min 8 n) -- keep number of digits and bits low to speed up tests-  let digits = take n' ['a' .. 'z']-  k <- choose (1,min 4 (n+1))-  return $ TestParms digits k--instance Arbitrary TestParms where-  arbitrary = sized sizedTestParms-  -prop_successive_values_differ_in_one_place2 :: TestParms -> Property-prop_successive_values_differ_in_one_place2 (TestParms ds k) = property $-  nub (diffCounts xs) == [1]-    where xs = naryGrayCodes ds k--diffCounts :: Eq b => [[b]] -> [Int]-diffCounts [] = []-diffCounts [_] = []-diffCounts (x1:x2:xs) = (diffCount x1 x2) : diffCounts (x2:xs)--diffCount :: Eq b => [b] -> [b] -> Int-diffCount as bs = length $ filter (\x -> x) $ zipWith (/=) as bs--prop_encoding_round_trippable :: Int -> Property-prop_encoding_round_trippable n =-  n >= 0 ==> (grayToIntegral . integralToGray $ n) == n--prop_decoding_round_trippable :: Int -> Property-prop_decoding_round_trippable n =-  n >= 0 ==> (integralToGray . grayToIntegral $ n) == n--prop_integralToGray_same_as_encode :: Word8 -> Property-prop_integralToGray_same_as_encode n =-  property $ integralToGray n == boolsToIntegral bits-    where bits = (grayCodes 8) !! (fromIntegral n)--boolsToIntegral :: Num c => [Bool] -> c-boolsToIntegral bs = f 0 1 . reverse $ bs-  where f total _ [] = total-        f total factor (b:bs') = f total' (factor*2) bs'-          where total' = if b then total + factor else total-                --- integralToBools :: (Integral a, Bits a) => a -> [Bool]--- integralToBools 0 = []--- integralToBools n = integralToBools (n `shiftR` 1) ++ [f (n `mod` 2)]---   where f 0 = False---         f 1 = True--test :: Test-test = testGroup "Codec.GrayQC"-  [-    testProperty "prop_successive_values_differ_in_one_place1"-      prop_successive_values_differ_in_one_place1,-    testProperty "prop_successive_values_differ_in_one_place2"-      prop_successive_values_differ_in_one_place2,-    testProperty "prop_encoding_round_trippable"-      prop_encoding_round_trippable,-    testProperty "prop_decoding_round_trippable"-      prop_decoding_round_trippable,-    testProperty "prop_integralToGray_same_as_encode"-      prop_integralToGray_same_as_encode-  ]--
− test/Main.hs
@@ -1,14 +0,0 @@-module Main where--import Codec.GrayQC ( test )--import Test.Framework as TF ( defaultMain, Test )--tests :: [TF.Test]-tests = -  [ -    Codec.GrayQC.test-  ]--main :: IO ()-main = defaultMain tests
+ test/TestMain.hs view
@@ -0,0 +1,14 @@+module Main where++import Codec.GrayQC ( test )++import Test.Framework as TF ( defaultMain, Test )++tests :: [TF.Test]+tests = +  [ +    Codec.GrayQC.test+  ]++main :: IO ()+main = defaultMain tests