genvalidity-text 1.0.0.0 → 1.0.0.1
raw patch · 3 files changed
+25/−12 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- genvalidity-text.cabal +3/−3
- src/Data/GenValidity/Text.hs +8/−2
- test/Data/GenValidity/TextSpec.hs +14/−7
genvalidity-text.cabal view
@@ -1,18 +1,18 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.34.4.+-- This file has been generated from package.yaml by hpack version 0.34.6. -- -- see: https://github.com/sol/hpack name: genvalidity-text-version: 1.0.0.0+version: 1.0.0.1 synopsis: GenValidity support for Text category: Testing homepage: https://github.com/NorfairKing/validity#readme bug-reports: https://github.com/NorfairKing/validity/issues author: Tom Sydney Kerckhove maintainer: syd@cs-syd.eu-copyright: Copyright: (c) 2016-2021 Tom Sydney Kerckhove+copyright: Copyright: (c) 2016-2022 Tom Sydney Kerckhove license: MIT license-file: LICENSE build-type: Simple
src/Data/GenValidity/Text.hs view
@@ -68,11 +68,17 @@ -- | 'textWithoutAny c' generates a 'Text' value that does not contain any 'c'. textWithoutAny :: Char -> Gen ST.Text-textWithoutAny c = textWithoutAnyOf [c]+textWithoutAny c = doubleCheck $ genTextBy $ genValid `suchThat` predicate+ where+ doubleCheck = (`suchThat` (ST.all predicate))+ predicate = (/= c) -- | 'textWithoutAnyOf c' generates a 'Text' value that does not contain any character in 'ls'. textWithoutAnyOf :: String -> Gen ST.Text-textWithoutAnyOf cs = ST.pack <$> genListOf (genValid `suchThat` (`notElem` cs))+textWithoutAnyOf cs = doubleCheck $ genTextBy (genValid `suchThat` predicate)+ where+ doubleCheck = (`suchThat` (ST.all predicate))+ predicate = (`notElem` cs) -- | 'textAllCaps' generates a 'Text' value with only upper-case characters. textAllCaps :: Gen ST.Text
test/Data/GenValidity/TextSpec.hs view
@@ -13,7 +13,6 @@ import qualified Data.Text.Internal as ST import qualified Data.Text.Internal.Lazy as LT import qualified Data.Text.Lazy as LT-import Data.Word import Test.Hspec import Test.QuickCheck import Test.Validity@@ -25,12 +24,12 @@ [ unwords [ "arr: ", intercalate "," $- map (printf "%4d" :: Word16 -> String) $ A.toList arr off len+ map (printf "%4d") $ A.toList arr off len ], unwords [ "hexarr:", intercalate "," $- map (printf "%4x" :: Word16 -> String) $ A.toList arr off len+ map (printf "%4x") $ A.toList arr off len ], unwords ["off: ", show off], unwords ["len: ", show len]@@ -77,14 +76,22 @@ it "contains the given character" $ forAll arbitrary $ \c -> forAll (textWithA c) $ \t -> ST.unpack t `shouldSatisfy` elem c- describe "textWithoutAny" $+ describe "textWithoutAny" $ do+ it "works with \65533" $+ let c = '\65533'+ in forAll (textWithoutAny c) $ \t ->+ ST.unpack t `shouldNotSatisfy` elem c it "never contains the given char" $- forAll arbitrary $ \c ->+ forAllShrink arbitrary shrink $ \c -> forAll (textWithoutAny c) $ \t -> ST.unpack t `shouldNotSatisfy` elem c- describe "textWithoutAnyOf" $+ describe "textWithoutAnyOf" $ do+ it "works with \65533" $+ let cs = "\65533"+ in forAll (textWithoutAnyOf cs) $ \text ->+ ST.unpack text `shouldNotSatisfy` (\t -> any (`elem` t) cs) it "never contains any of the given chars" $- forAll arbitrary $ \cs ->+ forAllShrink arbitrary shrink $ \cs -> forAll (textWithoutAnyOf cs) $ \text -> ST.unpack text `shouldNotSatisfy` (\t -> any (`elem` t) cs) describe "Lazy Text" $ do