genvalidity 0.9.0.0 → 0.9.0.1
raw patch · 2 files changed
+60/−66 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- genvalidity.cabal +2/−2
- test/Data/GenValiditySpec.hs +58/−64
genvalidity.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 3d07fce4934c73cfac46cfa5af2b300057a30ab9e210241338c4326cecc2c1f0+-- hash: f4100c2ff93efc9358e859fdff17d5b68f1a71aed4f88e4bcf2dd2e57ae0a795 name: genvalidity-version: 0.9.0.0+version: 0.9.0.1 synopsis: Testing utilities for the validity library description: Note: There are companion instance packages for this library: .
test/Data/GenValiditySpec.hs view
@@ -1,6 +1,6 @@ module Data.GenValiditySpec- ( spec- ) where+ ( spec+ ) where import Test.Hspec import Test.QuickCheck@@ -9,65 +9,59 @@ spec :: Spec spec = do- describe "upTo" $ do- it "returns only positive integers" $- forAll arbitrary $ \n -> forAll (upTo n) (`shouldSatisfy` (>= 0))- it "returns only integers smaller than or equal to the given number" $- forAll arbitrary $ \n ->- forAll (upTo n) (`shouldSatisfy` (<= (max n 0)))- describe "genSplit" $ do- it "returns positive integers" $- forAll arbitrary $ \i ->- forAll (genSplit i) $ \(a, b) -> do- a `shouldSatisfy` (>= 0)- b `shouldSatisfy` (>= 0)- it "returns two integers such that the sum is the original integer" $- forAll arbitrary $ \i ->- forAll (genSplit i) $ \(a, b) -> a + b `shouldBe` max 0 i- describe "genSplit3" $ do- it "returns positive integers" $- forAll arbitrary $ \i ->- forAll (genSplit3 i) $ \(a, b, c) -> do- a `shouldSatisfy` (>= 0)- b `shouldSatisfy` (>= 0)- c `shouldSatisfy` (>= 0)- it "returns three integers such that the sum is the original integer" $- forAll arbitrary $ \i ->- forAll (genSplit3 i) $ \(a, b, c) ->- a + b + c `shouldBe` max 0 i- describe "genSplit4" $ do- it "returns positive integers" $- forAll arbitrary $ \i ->- forAll (genSplit4 i) $ \(a, b, c, d) -> do- a `shouldSatisfy` (>= 0)- b `shouldSatisfy` (>= 0)- c `shouldSatisfy` (>= 0)- d `shouldSatisfy` (>= 0)- it "returns four integers such that the sum is the original integer" $- forAll arbitrary $ \i ->- forAll (genSplit4 i) $ \(a, b, c, d) ->- a + b + c + d `shouldBe` max 0 i- describe "genSplit5" $ do- it "returns positive integers" $- forAll arbitrary $ \i ->- forAll (genSplit5 i) $ \(a, b, c, d, e) -> do- a `shouldSatisfy` (>= 0)- b `shouldSatisfy` (>= 0)- c `shouldSatisfy` (>= 0)- d `shouldSatisfy` (>= 0)- e `shouldSatisfy` (>= 0)- it "returns four integers such that the sum is the original integer" $- forAll arbitrary $ \i ->- forAll (genSplit5 i) $ \(a, b, c, d, e) ->- a + b + c + d + e `shouldBe` max 0 i- describe "arbPartition" $ do- it "returns an empty list upon strictly negative input" $- forAll (arbitrary `suchThat` (< 0)) $ \n ->- forAll (arbPartition n) (`shouldBe` [])- it "returns a list of strictly positive integers" $- forAll arbitrary $ \n ->- forAll (arbPartition n) $ \p -> p `shouldSatisfy` all (> 0)- it- "returns a list of integers that sum to the original positive integer" $- forAll (arbitrary `suchThat` (>= 0)) $ \n ->- forAll (arbPartition n) $ \p -> sum p `shouldBe` n+ describe "genUtf16SurrogateCodePoint" $+ it "generates Utf16 surrogate codepoints" $+ forAll genUtf16SurrogateCodePoint $ (`shouldSatisfy` isUtf16SurrogateCodePoint)+ describe "upTo" $ do+ it "returns only positive integers" $+ forAll arbitrary $ \n -> forAll (upTo n) (`shouldSatisfy` (>= 0))+ it "returns only integers smaller than or equal to the given number" $+ forAll arbitrary $ \n -> forAll (upTo n) (`shouldSatisfy` (<= (max n 0)))+ describe "genSplit" $ do+ it "returns positive integers" $+ forAll arbitrary $ \i ->+ forAll (genSplit i) $ \(a, b) -> do+ a `shouldSatisfy` (>= 0)+ b `shouldSatisfy` (>= 0)+ it "returns two integers such that the sum is the original integer" $+ forAll arbitrary $ \i -> forAll (genSplit i) $ \(a, b) -> a + b `shouldBe` max 0 i+ describe "genSplit3" $ do+ it "returns positive integers" $+ forAll arbitrary $ \i ->+ forAll (genSplit3 i) $ \(a, b, c) -> do+ a `shouldSatisfy` (>= 0)+ b `shouldSatisfy` (>= 0)+ c `shouldSatisfy` (>= 0)+ it "returns three integers such that the sum is the original integer" $+ forAll arbitrary $ \i -> forAll (genSplit3 i) $ \(a, b, c) -> a + b + c `shouldBe` max 0 i+ describe "genSplit4" $ do+ it "returns positive integers" $+ forAll arbitrary $ \i ->+ forAll (genSplit4 i) $ \(a, b, c, d) -> do+ a `shouldSatisfy` (>= 0)+ b `shouldSatisfy` (>= 0)+ c `shouldSatisfy` (>= 0)+ d `shouldSatisfy` (>= 0)+ it "returns four integers such that the sum is the original integer" $+ forAll arbitrary $ \i ->+ forAll (genSplit4 i) $ \(a, b, c, d) -> a + b + c + d `shouldBe` max 0 i+ describe "genSplit5" $ do+ it "returns positive integers" $+ forAll arbitrary $ \i ->+ forAll (genSplit5 i) $ \(a, b, c, d, e) -> do+ a `shouldSatisfy` (>= 0)+ b `shouldSatisfy` (>= 0)+ c `shouldSatisfy` (>= 0)+ d `shouldSatisfy` (>= 0)+ e `shouldSatisfy` (>= 0)+ it "returns four integers such that the sum is the original integer" $+ forAll arbitrary $ \i ->+ forAll (genSplit5 i) $ \(a, b, c, d, e) -> a + b + c + d + e `shouldBe` max 0 i+ describe "arbPartition" $ do+ it "returns an empty list upon strictly negative input" $+ forAll (arbitrary `suchThat` (< 0)) $ \n -> forAll (arbPartition n) (`shouldBe` [])+ it "returns a list of strictly positive integers" $+ forAll arbitrary $ \n -> forAll (arbPartition n) $ \p -> p `shouldSatisfy` all (> 0)+ it "returns a list of integers that sum to the original positive integer" $+ forAll (arbitrary `suchThat` (>= 0)) $ \n ->+ forAll (arbPartition n) $ \p -> sum p `shouldBe` n