packages feed

hw-bits 0.7.0.7 → 0.7.0.8

raw patch · 5 files changed

+303/−270 lines, 5 filesdep −QuickCheckPVP ok

version bump matches the API change (PVP)

Dependencies removed: QuickCheck

API changes (from Hackage documentation)

Files

hw-bits.cabal view
@@ -1,22 +1,21 @@ cabal-version:  2.2 -name:           hw-bits-version:        0.7.0.7-synopsis:       Bit manipulation-description:    Please see README.md-category:       Data, Bit-stability:      Experimental-homepage:       http://github.com/haskell-works/hw-bits#readme-bug-reports:    https://github.com/haskell-works/hw-bits/issues-author:         John Ky-maintainer:     newhoggy@gmail.com-copyright:      2016-2019 John Ky-license:        BSD-3-Clause-license-file:   LICENSE-tested-with:    GHC == 8.6.5, GHC == 8.4.4, GHC == 8.2.2-build-type:     Simple-extra-source-files:-    README.md+name:                   hw-bits+version:                0.7.0.8+synopsis:               Bit manipulation+description:            Please see README.md+category:               Data, Bit+stability:              Experimental+homepage:               http://github.com/haskell-works/hw-bits#readme+bug-reports:            https://github.com/haskell-works/hw-bits/issues+author:                 John Ky+maintainer:             newhoggy@gmail.com+copyright:              2016-2019 John Ky+license:                BSD-3-Clause+license-file:           LICENSE+tested-with:            GHC == 8.8.1, GHC == 8.6.5, GHC == 8.4.4, GHC == 8.2.2+build-type:             Simple+extra-source-files:     README.md  source-repository head   type: git@@ -29,7 +28,6 @@  common base                 { build-depends: base                 >= 4          && < 5      } -common QuickCheck           { build-depends: QuickCheck           >= 2.10       && < 2.14   } common bytestring           { build-depends: bytestring           >= 0.9        && < 0.11   } common criterion            { build-depends: criterion            >= 1.2        && < 1.6    } common hedgehog             { build-depends: hedgehog             >= 0.6        && < 1.1    }@@ -41,82 +39,79 @@ common vector               { build-depends: vector               >= 0.12       && < 0.13   }  common common-  default-language:   Haskell2010-  ghc-options:        -Wall -O2+  default-language:     Haskell2010+  ghc-options:          -Wall -O2   if flag(sse42)-    ghc-options:      -msse4.2+    ghc-options:        -msse4.2  library-  import:   base-          , common-          , bytestring-          , hw-int-          , hw-prim-          , hw-string-parse-          , vector-  exposed-modules:-      HaskellWorks.Data.Bits-      HaskellWorks.Data.Bits.AllExcess-      HaskellWorks.Data.Bits.AllExcess.AllExcess0-      HaskellWorks.Data.Bits.AllExcess.AllExcess1-      HaskellWorks.Data.Bits.BitLength-      HaskellWorks.Data.Bits.BitParse-      HaskellWorks.Data.Bits.BitRead-      HaskellWorks.Data.Bits.BitShow-      HaskellWorks.Data.Bits.BitShown-      HaskellWorks.Data.Bits.BitWise-      HaskellWorks.Data.Bits.Broadword-      HaskellWorks.Data.Bits.ElemFixedBitSize-      HaskellWorks.Data.Bits.FixedBitSize-      HaskellWorks.Data.Bits.FromBitTextByteString-      HaskellWorks.Data.Bits.LoBitsSized-      HaskellWorks.Data.Bits.Log2-      HaskellWorks.Data.Bits.PopCount-      HaskellWorks.Data.Bits.PopCount.PopCount0-      HaskellWorks.Data.Bits.PopCount.PopCount1-      HaskellWorks.Data.Bits.Types.Broadword-      HaskellWorks.Data.Bits.Types.Builtin-      HaskellWorks.Data.Bits.Word-      HaskellWorks.Data.Bits.Writer.Storable-  other-modules:      Paths_hw_bits-  autogen-modules:    Paths_hw_bits-  hs-source-dirs:     src+  import:               base+                      , common+                      , bytestring+                      , hw-int+                      , hw-prim+                      , hw-string-parse+                      , vector+  exposed-modules:      HaskellWorks.Data.Bits+                        HaskellWorks.Data.Bits.AllExcess+                        HaskellWorks.Data.Bits.AllExcess.AllExcess0+                        HaskellWorks.Data.Bits.AllExcess.AllExcess1+                        HaskellWorks.Data.Bits.BitLength+                        HaskellWorks.Data.Bits.BitParse+                        HaskellWorks.Data.Bits.BitRead+                        HaskellWorks.Data.Bits.BitShow+                        HaskellWorks.Data.Bits.BitShown+                        HaskellWorks.Data.Bits.BitWise+                        HaskellWorks.Data.Bits.Broadword+                        HaskellWorks.Data.Bits.ElemFixedBitSize+                        HaskellWorks.Data.Bits.FixedBitSize+                        HaskellWorks.Data.Bits.FromBitTextByteString+                        HaskellWorks.Data.Bits.LoBitsSized+                        HaskellWorks.Data.Bits.Log2+                        HaskellWorks.Data.Bits.PopCount+                        HaskellWorks.Data.Bits.PopCount.PopCount0+                        HaskellWorks.Data.Bits.PopCount.PopCount1+                        HaskellWorks.Data.Bits.Types.Broadword+                        HaskellWorks.Data.Bits.Types.Builtin+                        HaskellWorks.Data.Bits.Word+                        HaskellWorks.Data.Bits.Writer.Storable+  other-modules:        Paths_hw_bits+  autogen-modules:      Paths_hw_bits+  hs-source-dirs:       src  test-suite hw-bits-test-  import:   base-          , common-          , QuickCheck-          , bytestring-          , hedgehog-          , hspec-          , hw-hspec-hedgehog-          , hw-prim-          , vector-  build-depends:      hw-bits-  type:               exitcode-stdio-1.0-  main-is:            Spec.hs-  build-depends:      hw-bits-  other-modules:-      HaskellWorks.Data.Bits.BitReadSpec-      HaskellWorks.Data.Bits.BitWiseSpec-      HaskellWorks.Data.Bits.FromBitTextByteStringSpec-      HaskellWorks.Data.Bits.Log2Spec-      HaskellWorks.Data.Bits.Writer.StorableSpec-      Paths_hw_bits-  autogen-modules:    Paths_hw_bits-  hs-source-dirs:     test-  ghc-options:        -threaded -rtsopts -with-rtsopts=-N-  build-tool-depends: hspec-discover:hspec-discover+  import:               base+                      , common+                      , bytestring+                      , hedgehog+                      , hspec+                      , hw-hspec-hedgehog+                      , hw-prim+                      , vector+  build-depends:        hw-bits+  type:                 exitcode-stdio-1.0+  main-is:              Spec.hs+  build-depends:        hw-bits+  other-modules:        HaskellWorks.Data.Bits.BitReadSpec+                        HaskellWorks.Data.Bits.BitWiseSpec+                        HaskellWorks.Data.Bits.FromBitTextByteStringSpec+                        HaskellWorks.Data.Bits.Log2Spec+                        HaskellWorks.Data.Bits.Writer.StorableSpec+                        Paths_hw_bits+  autogen-modules:      Paths_hw_bits+  hs-source-dirs:       test+  ghc-options:          -threaded -rtsopts -with-rtsopts=-N+  build-tool-depends:   hspec-discover:hspec-discover  benchmark bench-  import:   base-          , common-          , criterion-          , vector-  build-depends:      hw-bits-  type:               exitcode-stdio-1.0-  main-is:            Main.hs-  build-depends:      hw-bits-  other-modules:      Paths_hw_bits-  autogen-modules:    Paths_hw_bits-  hs-source-dirs:     bench+  import:               base+                      , common+                      , criterion+                      , vector+  build-depends:        hw-bits+  type:                 exitcode-stdio-1.0+  main-is:              Main.hs+  build-depends:        hw-bits+  other-modules:        Paths_hw_bits+  autogen-modules:      Paths_hw_bits+  hs-source-dirs:       bench
test/HaskellWorks/Data/Bits/BitReadSpec.hs view
@@ -1,49 +1,52 @@ {-# OPTIONS_GHC -fno-warn-incomplete-patterns #-}-{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE OverloadedLists     #-}+{-# LANGUAGE ScopedTypeVariables #-}  module HaskellWorks.Data.Bits.BitReadSpec (spec) where -import qualified Data.Vector                    as DV-import           Data.Word-import           HaskellWorks.Data.Bits.BitRead-import           HaskellWorks.Data.Bits.BitShow-import           Test.Hspec+import Data.Word+import HaskellWorks.Data.Bits.BitRead+import HaskellWorks.Data.Bits.BitShow+import HaskellWorks.Hspec.Hedgehog+import Hedgehog+import Test.Hspec +import qualified Data.Vector as DV+ {-# ANN module ("HLint: Ignore Redundant do" :: String) #-}  spec :: Spec spec = describe "HaskellWorks.Data.BitReadSpec" $ do-  it "bitRead \"10000000 101\" :: Maybe [Word8]" $-    let w = bitRead "10000000 101" :: Maybe [Bool] in-    w `shouldBe` Just [True, False, False, False, False, False, False, False, True, False, True]-  it "bitRead \"10000000 101\" :: Maybe [Word8]"$-    let w = bitRead "10000000 101" :: Maybe [Word8] in-    w `shouldBe` Just [1, 5]-  it "bitRead \"11100100 10101111 1\" :: Maybe [Word8]" $-    let ws = bitRead "11100100 10101111 1" :: Maybe [Word8] in-    ws `shouldBe` Just [39, 245, 1]-  it "bitRead \"\" :: Maybe [Word8]" $-    let ws = bitRead "" :: Maybe [Word8] in-    ws `shouldBe` Just []-  it "bitRead \"10000000 101\" :: Maybe (DV.Vector Word8)" $-    let v = bitRead "10000000 101" :: Maybe (DV.Vector Word8) in-    v `shouldBe` Just [1, 5]-  it "bitRead \"11100100 10101111 1\" :: Maybe (DV.Vector Word8)" $-    let v = bitRead "11100100 10101111 1" :: Maybe (DV.Vector Word8) in-    v `shouldBe` Just [39, 245, 1]-  it "bitRead \"11100100 10101111 1\" :: Maybe (DV.Vector Word16)" $-    let v = bitRead "11100100 10101111 1" :: Maybe (DV.Vector Word16) in-    v `shouldBe` Just [39 + 62720, 1]-  it "bitRead \"\" :: Maybe (DV.Vector Word8)" $-    let v = bitRead "" :: Maybe (DV.Vector Word8) in-    v `shouldBe` Just []-  it "bitShow (8 :: Word8)" $-    let bs = bitShow (8 :: Word8) in-    bs `shouldBe` "00010000"-  it "bitShow (8 :: Word64)" $-    let bs = bitShow (8 :: Word64) in-    bs `shouldBe` "00010000 00000000 00000000 00000000 00000000 00000000 00000000 00000000"-  it "bitShow [0x0102040810204080 :: Word64]" $-    let bs = bitShow ([0x0102040810204080] :: [Word64]) in-    bs `shouldBe` "00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000"+  it "bitRead \"10000000 101\" :: Maybe [Word8]" . requireTest $ do+    let w = bitRead "10000000 101" :: Maybe [Bool]+    w === Just [True, False, False, False, False, False, False, False, True, False, True]+  it "bitRead \"10000000 101\" :: Maybe [Word8]" $ requireTest $ do+    let w = bitRead "10000000 101" :: Maybe [Word8]+    w === Just [1, 5]+  it "bitRead \"11100100 10101111 1\" :: Maybe [Word8]" . requireTest $ do+    let ws = bitRead "11100100 10101111 1" :: Maybe [Word8]+    ws === Just [39, 245, 1]+  it "bitRead \"\" :: Maybe [Word8]" . requireTest $ do+    let ws = bitRead "" :: Maybe [Word8]+    ws === Just []+  it "bitRead \"10000000 101\" :: Maybe (DV.Vector Word8)" . requireTest $ do+    let v = bitRead "10000000 101" :: Maybe (DV.Vector Word8)+    v === Just [1, 5]+  it "bitRead \"11100100 10101111 1\" :: Maybe (DV.Vector Word8)" . requireTest $ do+    let v = bitRead "11100100 10101111 1" :: Maybe (DV.Vector Word8)+    v === Just [39, 245, 1]+  it "bitRead \"11100100 10101111 1\" :: Maybe (DV.Vector Word16)" . requireTest $ do+    let v = bitRead "11100100 10101111 1" :: Maybe (DV.Vector Word16)+    v === Just [39 + 62720, 1]+  it "bitRead \"\" :: Maybe (DV.Vector Word8)" . requireTest $ do+    let v = bitRead "" :: Maybe (DV.Vector Word8)+    v === Just []+  it "bitShow (8 :: Word8)" . requireTest $ do+    let bs = bitShow (8 :: Word8)+    bs === "00010000"+  it "bitShow (8 :: Word64)" . requireTest $ do+    let bs = bitShow (8 :: Word64)+    bs === "00010000 00000000 00000000 00000000 00000000 00000000 00000000 00000000"+  it "bitShow [0x0102040810204080 :: Word64]" . requireTest $ do+    let bs = bitShow ([0x0102040810204080] :: [Word64])+    bs === "00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000"
test/HaskellWorks/Data/Bits/BitWiseSpec.hs view
@@ -3,66 +3,93 @@  module HaskellWorks.Data.Bits.BitWiseSpec (spec) where -import qualified Data.Bits                                 as B-import qualified Data.Vector.Storable                      as DVS-import           Data.Word-import           HaskellWorks.Data.Bits.BitLength-import           HaskellWorks.Data.Bits.PopCount.PopCount0-import           HaskellWorks.Data.Bits.PopCount.PopCount1-import           Test.Hspec-import           Test.QuickCheck+import HaskellWorks.Data.Bits.BitLength+import HaskellWorks.Data.Bits.PopCount.PopCount0+import HaskellWorks.Data.Bits.PopCount.PopCount1+import HaskellWorks.Hspec.Hedgehog+import Hedgehog+import Test.Hspec +import qualified Data.Bits            as B+import qualified Data.Vector.Storable as DVS+import qualified Hedgehog.Gen         as G+import qualified Hedgehog.Range       as R+ {-# ANN module ("HLint: ignore Redundant do" :: String) #-}  spec :: Spec spec = describe "HaskellWorks.Data.Bits.BitWiseSpec" $ do   describe "for popCount0" $ do-    it "for Word8 matches Data.Bits implementation" $ property $-      \(w :: Word8 ) -> popCount0 w == bitLength w - fromIntegral (B.popCount w)-    it "for Word16 matches Data.Bits implementation" $ property $-      \(w :: Word16) -> popCount0 w == bitLength w - fromIntegral (B.popCount w)-    it "for Word32 matches Data.Bits implementation" $ property $-      \(w :: Word32) -> popCount0 w == bitLength w - fromIntegral (B.popCount w)-    it "for Word64 matches Data.Bits implementation" $ property $-      \(w :: Word64) -> popCount0 w == bitLength w - fromIntegral (B.popCount w)-    it "for [Word8] matches Data.Bits implementation" $ property $-      \(w :: [Word8] ) -> popCount0 w == bitLength w - sum (fmap (fromIntegral . B.popCount) w)-    it "for [Word16] matches Data.Bits implementation" $ property $-      \(w :: [Word16]) -> popCount0 w == bitLength w - sum (fmap (fromIntegral . B.popCount) w)-    it "for [Word32] matches Data.Bits implementation" $ property $-      \(w :: [Word32]) -> popCount0 w == bitLength w - sum (fmap (fromIntegral . B.popCount) w)-    it "for [Word64] matches Data.Bits implementation" $ property $-      \(w :: [Word64]) -> popCount0 w == bitLength w - sum (fmap (fromIntegral . B.popCount) w)-    it "for [Word8] matches Data.Bits implementation" $ property $-      \(w :: [Word8] ) -> popCount0 w == popCount0 (DVS.fromList w)-    it "for [Word16] matches Data.Bits implementation" $ property $-      \(w :: [Word16]) -> popCount0 w == popCount0 (DVS.fromList w)-    it "for [Word32] matches Data.Bits implementation" $ property $-      \(w :: [Word32]) -> popCount0 w == popCount0 (DVS.fromList w)-    it "for [Word64] matches Data.Bits implementation" $ property $-      \(w :: [Word64]) -> popCount0 w == popCount0 (DVS.fromList w)+    it "for Word8 matches Data.Bits implementation" $ requireProperty $ do+      w <- forAll $ G.word8 R.constantBounded+      popCount0 w === bitLength w - fromIntegral (B.popCount w)+    it "for Word16 matches Data.Bits implementation" $ requireProperty $ do+      w <- forAll $ G.word16 R.constantBounded+      popCount0 w === bitLength w - fromIntegral (B.popCount w)+    it "for Word32 matches Data.Bits implementation" $ requireProperty $ do+      w <- forAll $ G.word32 R.constantBounded+      popCount0 w === bitLength w - fromIntegral (B.popCount w)+    it "for Word64 matches Data.Bits implementation" $ requireProperty $ do+      w <- forAll $ G.word64 R.constantBounded+      popCount0 w === bitLength w - fromIntegral (B.popCount w)+    it "for [Word8] matches Data.Bits implementation" $ requireProperty $ do+      w <- forAll $ G.list (R.constant 0 10) (G.word8 R.constantBounded)+      popCount0 w === bitLength w - sum (fmap (fromIntegral . B.popCount) w)+    it "for [Word16] matches Data.Bits implementation" $ requireProperty $ do+      w <- forAll $ G.list (R.constant 0 10) (G.word16 R.constantBounded)+      popCount0 w === bitLength w - sum (fmap (fromIntegral . B.popCount) w)+    it "for [Word32] matches Data.Bits implementation" $ requireProperty $ do+      w <- forAll $ G.list (R.constant 0 10) (G.word32 R.constantBounded)+      popCount0 w === bitLength w - sum (fmap (fromIntegral . B.popCount) w)+    it "for [Word64] matches Data.Bits implementation" $ requireProperty $ do+      w <- forAll $ G.list (R.constant 0 10) (G.word64 R.constantBounded)+      popCount0 w === bitLength w - sum (fmap (fromIntegral . B.popCount) w)+    it "for [Word8] matches Data.Bits implementation" $ requireProperty $ do+      w <- forAll $ G.list (R.constant 0 10) (G.word8 R.constantBounded)+      popCount0 w === popCount0 (DVS.fromList w)+    it "for [Word16] matches Data.Bits implementation" $ requireProperty $ do+      w <- forAll $ G.list (R.constant 0 10) (G.word16 R.constantBounded)+      popCount0 w === popCount0 (DVS.fromList w)+    it "for [Word32] matches Data.Bits implementation" $ requireProperty $ do+      w <- forAll $ G.list (R.constant 0 10) (G.word32 R.constantBounded)+      popCount0 w === popCount0 (DVS.fromList w)+    it "for [Word64] matches Data.Bits implementation" $ requireProperty $ do+      w <- forAll $ G.list (R.constant 0 10) (G.word64 R.constantBounded)+      popCount0 w === popCount0 (DVS.fromList w)   describe "for popCount1" $ do-    it "for Word8 matches Data.Bits implementation" $ property $-      \(w :: Word8 ) -> popCount1 w == fromIntegral (B.popCount w)-    it "for Word16 matches Data.Bits implementation" $ property $-      \(w :: Word16) -> popCount1 w == fromIntegral (B.popCount w)-    it "for Word32 matches Data.Bits implementation" $ property $-      \(w :: Word32) -> popCount1 w == fromIntegral (B.popCount w)-    it "for Word64 matches Data.Bits implementation" $ property $-      \(w :: Word64) -> popCount1 w == fromIntegral (B.popCount w)-    it "for [Word8] matches Data.Bits implementation" $ property $-      \(w :: [Word8] ) -> popCount1 w == sum (fmap (fromIntegral . B.popCount) w)-    it "for [Word16] matches Data.Bits implementation" $ property $-      \(w :: [Word16]) -> popCount1 w == sum (fmap (fromIntegral . B.popCount) w)-    it "for [Word32] matches Data.Bits implementation" $ property $-      \(w :: [Word32]) -> popCount1 w == sum (fmap (fromIntegral . B.popCount) w)-    it "for [Word64] matches Data.Bits implementation" $ property $-      \(w :: [Word64]) -> popCount1 w == sum (fmap (fromIntegral . B.popCount) w)-    it "for [Word8] matches Data.Bits implementation" $ property $-      \(w :: [Word8] ) -> popCount1 w == popCount1 (DVS.fromList w)-    it "for [Word16] matches Data.Bits implementation" $ property $-      \(w :: [Word16]) -> popCount1 w == popCount1 (DVS.fromList w)-    it "for [Word32] matches Data.Bits implementation" $ property $-      \(w :: [Word32]) -> popCount1 w == popCount1 (DVS.fromList w)-    it "for [Word64] matches Data.Bits implementation" $ property $-      \(w :: [Word64]) -> popCount1 w == popCount1 (DVS.fromList w)+    it "for Word8 matches Data.Bits implementation" $ requireProperty $ do+      w <- forAll $ G.word8 R.constantBounded+      popCount1 w === fromIntegral (B.popCount w)+    it "for Word16 matches Data.Bits implementation" $ requireProperty $ do+      w <- forAll $ G.word16 R.constantBounded+      popCount1 w === fromIntegral (B.popCount w)+    it "for Word32 matches Data.Bits implementation" $ requireProperty $ do+      w <- forAll $ G.word32 R.constantBounded+      popCount1 w === fromIntegral (B.popCount w)+    it "for Word64 matches Data.Bits implementation" $ requireProperty $ do+      w <- forAll $ G.word64 R.constantBounded+      popCount1 w === fromIntegral (B.popCount w)+    it "for [Word8] matches Data.Bits implementation" $ requireProperty $ do+      w <- forAll $ G.list (R.constant 0 10) (G.word8 R.constantBounded)+      popCount1 w === sum (fmap (fromIntegral . B.popCount) w)+    it "for [Word16] matches Data.Bits implementation" $ requireProperty $ do+      w <- forAll $ G.list (R.constant 0 10) (G.word16 R.constantBounded)+      popCount1 w === sum (fmap (fromIntegral . B.popCount) w)+    it "for [Word32] matches Data.Bits implementation" $ requireProperty $ do+      w <- forAll $ G.list (R.constant 0 10) (G.word32 R.constantBounded)+      popCount1 w === sum (fmap (fromIntegral . B.popCount) w)+    it "for [Word64] matches Data.Bits implementation" $ requireProperty $ do+      w <- forAll $ G.list (R.constant 0 10) (G.word64 R.constantBounded)+      popCount1 w === sum (fmap (fromIntegral . B.popCount) w)+    it "for [Word8] matches Data.Bits implementation" $ requireProperty $ do+      w <- forAll $ G.list (R.constant 0 10) (G.word8 R.constantBounded)+      popCount1 w === popCount1 (DVS.fromList w)+    it "for [Word16] matches Data.Bits implementation" $ requireProperty $ do+      w <- forAll $ G.list (R.constant 0 10) (G.word16 R.constantBounded)+      popCount1 w === popCount1 (DVS.fromList w)+    it "for [Word32] matches Data.Bits implementation" $ requireProperty $ do+      w <- forAll $ G.list (R.constant 0 10) (G.word32 R.constantBounded)+      popCount1 w === popCount1 (DVS.fromList w)+    it "for [Word64] matches Data.Bits implementation" $ requireProperty $ do+      w <- forAll $ G.list (R.constant 0 10) (G.word64 R.constantBounded)+      popCount1 w === popCount1 (DVS.fromList w)
test/HaskellWorks/Data/Bits/FromBitTextByteStringSpec.hs view
@@ -6,89 +6,92 @@  module HaskellWorks.Data.Bits.FromBitTextByteStringSpec (spec) where -import qualified Data.ByteString                              as BS-import qualified Data.Vector.Storable                         as DVS-import           Data.Word-import           HaskellWorks.Data.Bits.FromBitTextByteString-import           Test.Hspec+import Data.Word+import HaskellWorks.Data.Bits.FromBitTextByteString+import HaskellWorks.Hspec.Hedgehog+import Hedgehog+import Test.Hspec +import qualified Data.ByteString      as BS+import qualified Data.Vector.Storable as DVS+ {-# ANN module ("HLint: Ignore Redundant do" :: String) #-}  spec :: Spec spec = describe "HaskellWorks.Data.Bits.FromBitTextByteStringSpec" $ do   describe "For (DVS.Vector Word8)" $ do-    it "fromBitTextByteString (BS.unpack []) :: DVS.Vector Word8" $-      let w = fromBitTextByteString (BS.pack []) ::DVS.Vector Word8 in-      w `shouldBe` DVS.fromList []-    it "fromBitTextByteString (BS.unpack \"0\") :: DVS.Vector Word8" $-      let w = fromBitTextByteString "0" ::DVS.Vector Word8 in-      w `shouldBe` DVS.fromList [0x0]-    it "fromBitTextByteString (BS.unpack \"1\") :: DVS.Vector Word8" $-      let w = fromBitTextByteString "1" ::DVS.Vector Word8 in-      w `shouldBe` DVS.fromList [0x1]-    it "fromBitTextByteString (BS.unpack \"11110000\") :: DVS.Vector Word8" $-      let w = fromBitTextByteString "11110000" ::DVS.Vector Word8 in-      w `shouldBe` DVS.fromList [0x0f]-    it "fromBitTextByteString (BS.unpack \"111100000\") :: DVS.Vector Word8" $-      let w = fromBitTextByteString "111100000" ::DVS.Vector Word8 in-      w `shouldBe` DVS.fromList [0x0f, 0x0]-    it "fromBitTextByteString (BS.unpack \"111100001\") :: DVS.Vector Word8" $-      let w = fromBitTextByteString "111100001" ::DVS.Vector Word8 in-      w `shouldBe` DVS.fromList [0x0f, 0x1]+    it "fromBitTextByteString (BS.unpack []) :: DVS.Vector Word8" . requireTest $ do+      let w = fromBitTextByteString (BS.pack []) :: DVS.Vector Word8+      w === DVS.fromList []+    it "fromBitTextByteString (BS.unpack \"0\") :: DVS.Vector Word8" . requireTest $ do+      let w = fromBitTextByteString "0" :: DVS.Vector Word8+      w === DVS.fromList [0x0]+    it "fromBitTextByteString (BS.unpack \"1\") :: DVS.Vector Word8" . requireTest $ do+      let w = fromBitTextByteString "1" :: DVS.Vector Word8+      w === DVS.fromList [0x1]+    it "fromBitTextByteString (BS.unpack \"11110000\") :: DVS.Vector Word8" . requireTest $ do+      let w = fromBitTextByteString "11110000" :: DVS.Vector Word8+      w === DVS.fromList [0x0f]+    it "fromBitTextByteString (BS.unpack \"111100000\") :: DVS.Vector Word8" . requireTest $ do+      let w = fromBitTextByteString "111100000" :: DVS.Vector Word8+      w === DVS.fromList [0x0f, 0x0]+    it "fromBitTextByteString (BS.unpack \"111100001\") :: DVS.Vector Word8" . requireTest $ do+      let w = fromBitTextByteString "111100001" :: DVS.Vector Word8+      w === DVS.fromList [0x0f, 0x1]   describe "For (DVS.Vector Word16)" $ do-    it "fromBitTextByteString (BS.unpack []) :: DVS.Vector Word16" $-      let w = fromBitTextByteString (BS.pack []) ::DVS.Vector Word16 in-      w `shouldBe` DVS.fromList []-    it "fromBitTextByteString (BS.unpack \"0\") :: DVS.Vector Word16" $-      let w = fromBitTextByteString "0" ::DVS.Vector Word16 in-      w `shouldBe` DVS.fromList [0x0]-    it "fromBitTextByteString (BS.unpack \"1\") :: DVS.Vector Word16" $-      let w = fromBitTextByteString "1" ::DVS.Vector Word16 in-      w `shouldBe` DVS.fromList [0x1]-    it "fromBitTextByteString (BS.unpack \"1111000011110000\") :: DVS.Vector Word16" $-      let w = fromBitTextByteString "1111000011110000" ::DVS.Vector Word16 in-      w `shouldBe` DVS.fromList [0x0f0f]-    it "fromBitTextByteString (BS.unpack \"11110000111100000\") :: DVS.Vector Word16" $-      let w = fromBitTextByteString "11110000111100000" ::DVS.Vector Word16 in-      w `shouldBe` DVS.fromList [0x0f0f, 0x0]-    it "fromBitTextByteString (BS.unpack \"11110000111100001\") :: DVS.Vector Word16" $-      let w = fromBitTextByteString "11110000111100001" ::DVS.Vector Word16 in-      w `shouldBe` DVS.fromList [0x0f0f, 0x1]+    it "fromBitTextByteString (BS.unpack []) :: DVS.Vector Word16" . requireTest $ do+      let w = fromBitTextByteString (BS.pack []) :: DVS.Vector Word16+      w === DVS.fromList []+    it "fromBitTextByteString (BS.unpack \"0\") :: DVS.Vector Word16" . requireTest $ do+      let w = fromBitTextByteString "0" :: DVS.Vector Word16+      w === DVS.fromList [0x0]+    it "fromBitTextByteString (BS.unpack \"1\") :: DVS.Vector Word16" . requireTest $ do+      let w = fromBitTextByteString "1" :: DVS.Vector Word16+      w === DVS.fromList [0x1]+    it "fromBitTextByteString (BS.unpack \"1111000011110000\") :: DVS.Vector Word16" . requireTest $ do+      let w = fromBitTextByteString "1111000011110000" :: DVS.Vector Word16+      w === DVS.fromList [0x0f0f]+    it "fromBitTextByteString (BS.unpack \"11110000111100000\") :: DVS.Vector Word16" . requireTest $ do+      let w = fromBitTextByteString "11110000111100000" :: DVS.Vector Word16+      w === DVS.fromList [0x0f0f, 0x0]+    it "fromBitTextByteString (BS.unpack \"11110000111100001\") :: DVS.Vector Word16" . requireTest $ do+      let w = fromBitTextByteString "11110000111100001" :: DVS.Vector Word16+      w === DVS.fromList [0x0f0f, 0x1]   describe "For (DVS.Vector Word32)" $ do-    it "fromBitTextByteString (BS.unpack []) :: DVS.Vector Word32" $-      let w = fromBitTextByteString (BS.pack []) ::DVS.Vector Word32 in-      w `shouldBe` DVS.fromList []-    it "fromBitTextByteString (BS.unpack \"0\") :: DVS.Vector Word32" $-      let w = fromBitTextByteString "0" ::DVS.Vector Word32 in-      w `shouldBe` DVS.fromList [0x0]-    it "fromBitTextByteString (BS.unpack \"1\") :: DVS.Vector Word32" $-      let w = fromBitTextByteString "1" ::DVS.Vector Word32 in-      w `shouldBe` DVS.fromList [0x1]-    it "fromBitTextByteString (BS.unpack \"11110000111100001111000011110000\") :: DVS.Vector Word32" $-      let w = fromBitTextByteString "11110000111100001111000011110000" ::DVS.Vector Word32 in-      w `shouldBe` DVS.fromList [0x0f0f0f0f]-    it "fromBitTextByteString (BS.unpack \"111100001111000011110000111100000\") :: DVS.Vector Word32" $-      let w = fromBitTextByteString "111100001111000011110000111100000" ::DVS.Vector Word32 in-      w `shouldBe` DVS.fromList [0x0f0f0f0f, 0x0]-    it "fromBitTextByteString (BS.unpack \"111100001111000011110000111100001\") :: DVS.Vector Word32" $-      let w = fromBitTextByteString "111100001111000011110000111100001" ::DVS.Vector Word32 in-      w `shouldBe` DVS.fromList [0x0f0f0f0f, 0x1]+    it "fromBitTextByteString (BS.unpack []) :: DVS.Vector Word32" . requireTest $ do+      let w = fromBitTextByteString (BS.pack []) :: DVS.Vector Word32+      w === DVS.fromList []+    it "fromBitTextByteString (BS.unpack \"0\") :: DVS.Vector Word32" . requireTest $ do+      let w = fromBitTextByteString "0" :: DVS.Vector Word32+      w === DVS.fromList [0x0]+    it "fromBitTextByteString (BS.unpack \"1\") :: DVS.Vector Word32" . requireTest $ do+      let w = fromBitTextByteString "1" :: DVS.Vector Word32+      w === DVS.fromList [0x1]+    it "fromBitTextByteString (BS.unpack \"11110000111100001111000011110000\") :: DVS.Vector Word32" . requireTest $ do+      let w = fromBitTextByteString "11110000111100001111000011110000" :: DVS.Vector Word32+      w === DVS.fromList [0x0f0f0f0f]+    it "fromBitTextByteString (BS.unpack \"111100001111000011110000111100000\") :: DVS.Vector Word32" . requireTest $ do+      let w = fromBitTextByteString "111100001111000011110000111100000" :: DVS.Vector Word32+      w === DVS.fromList [0x0f0f0f0f, 0x0]+    it "fromBitTextByteString (BS.unpack \"111100001111000011110000111100001\") :: DVS.Vector Word32" . requireTest $ do+      let w = fromBitTextByteString "111100001111000011110000111100001" :: DVS.Vector Word32+      w === DVS.fromList [0x0f0f0f0f, 0x1]   describe "For (DVS.Vector Word64)" $ do-    it "fromBitTextByteString (BS.unpack []) :: DVS.Vector Word64" $-      let w = fromBitTextByteString (BS.pack []) ::DVS.Vector Word64 in-      w `shouldBe` DVS.fromList []-    it "fromBitTextByteString (BS.unpack \"0\") :: DVS.Vector Word64" $-      let w = fromBitTextByteString "0" ::DVS.Vector Word64 in-      w `shouldBe` DVS.fromList [0x0]-    it "fromBitTextByteString (BS.unpack \"1\") :: DVS.Vector Word64" $-      let w = fromBitTextByteString "1" ::DVS.Vector Word64 in-      w `shouldBe` DVS.fromList [0x1]-    it "fromBitTextByteString (BS.unpack \"1111000011110000111100001111000011110000111100001111000011110000\") :: DVS.Vector Word64" $-      let w = fromBitTextByteString "1111000011110000111100001111000011110000111100001111000011110000" ::DVS.Vector Word64 in-      w `shouldBe` DVS.fromList [0x0f0f0f0f0f0f0f0f]-    it "fromBitTextByteString (BS.unpack \"11110000111100001111000011110000111100001111000011110000111100000\") :: DVS.Vector Word64" $-      let w = fromBitTextByteString "11110000111100001111000011110000111100001111000011110000111100000" ::DVS.Vector Word64 in-      w `shouldBe` DVS.fromList [0x0f0f0f0f0f0f0f0f, 0x0]-    it "fromBitTextByteString (BS.unpack \"11110000111100001111000011110000111100001111000011110000111100001\") :: DVS.Vector Word64" $-      let w = fromBitTextByteString "11110000111100001111000011110000111100001111000011110000111100001" ::DVS.Vector Word64 in-      w `shouldBe` DVS.fromList [0x0f0f0f0f0f0f0f0f, 0x1]+    it "fromBitTextByteString (BS.unpack []) :: DVS.Vector Word64" . requireTest $ do+      let w = fromBitTextByteString (BS.pack []) :: DVS.Vector Word64+      w === DVS.fromList []+    it "fromBitTextByteString (BS.unpack \"0\") :: DVS.Vector Word64" . requireTest $ do+      let w = fromBitTextByteString "0" :: DVS.Vector Word64+      w === DVS.fromList [0x0]+    it "fromBitTextByteString (BS.unpack \"1\") :: DVS.Vector Word64" . requireTest $ do+      let w = fromBitTextByteString "1" :: DVS.Vector Word64+      w === DVS.fromList [0x1]+    it "fromBitTextByteString (BS.unpack \"1111000011110000111100001111000011110000111100001111000011110000\") :: DVS.Vector Word64" . requireTest $ do+      let w = fromBitTextByteString "1111000011110000111100001111000011110000111100001111000011110000" :: DVS.Vector Word64+      w === DVS.fromList [0x0f0f0f0f0f0f0f0f]+    it "fromBitTextByteString (BS.unpack \"11110000111100001111000011110000111100001111000011110000111100000\") :: DVS.Vector Word64" . requireTest $ do+      let w = fromBitTextByteString "11110000111100001111000011110000111100001111000011110000111100000" :: DVS.Vector Word64+      w === DVS.fromList [0x0f0f0f0f0f0f0f0f, 0x0]+    it "fromBitTextByteString (BS.unpack \"11110000111100001111000011110000111100001111000011110000111100001\") :: DVS.Vector Word64" . requireTest $ do+      let w = fromBitTextByteString "11110000111100001111000011110000111100001111000011110000111100001" :: DVS.Vector Word64+      w === DVS.fromList [0x0f0f0f0f0f0f0f0f, 0x1]
test/HaskellWorks/Data/Bits/Log2Spec.hs view
@@ -3,16 +3,21 @@  module HaskellWorks.Data.Bits.Log2Spec (spec) where -import           Data.Word-import           HaskellWorks.Data.Bits.Log2-import           Test.Hspec-import           Test.QuickCheck+import HaskellWorks.Data.Bits.Log2+import HaskellWorks.Hspec.Hedgehog+import Hedgehog+import Test.Hspec +import qualified Hedgehog.Gen   as G+import qualified Hedgehog.Range as R+ {-# ANN module ("HLint: Ignore Redundant do" :: String) #-}  spec :: Spec spec = describe "HaskellWorks.Data.Bits.Log2Spec" $ do-  it "Log2 Word64" $ property $-    \(NonZero (w :: Word64)) -> log2 w == floor (log (fromIntegral w) / log 2 :: Double)-  it "Log2 Word32" $ property $-    \(NonZero (w :: Word32)) -> log2 w == floor (log (fromIntegral w) / log 2 :: Double)+  it "Log2 Word64" . requireProperty $ do+    w <- forAll $ G.word64 (R.constant 1 maxBound)+    log2 w === floor (log (fromIntegral w) / log 2 :: Double)+  it "Log2 Word32" . requireProperty $ do+    w <- forAll $ G.word64 (R.constant 1 maxBound)+    log2 w === floor (log (fromIntegral w) / log 2 :: Double)