packages feed

genvalidity-text 0.3.1.1 → 0.4.0.0

raw patch · 3 files changed

+27/−25 lines, 3 filesdep ~genvaliditydep ~validitydep ~validity-textPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: genvalidity, validity, validity-text

API changes (from Hackage documentation)

- Data.GenValidity.Text: textWithoutAnyOf :: [Char] -> Gen Text
+ Data.GenValidity.Text: textWithoutAnyOf :: String -> Gen Text

Files

genvalidity-text.cabal view
@@ -1,5 +1,5 @@ name: genvalidity-text-version: 0.3.1.1+version: 0.4.0.0 cabal-version: >=1.10 build-type: Simple license: MIT@@ -22,9 +22,9 @@         Data.GenValidity.Text     build-depends:         base >=4.7 && <5,-        validity -any,-        validity-text >= 0.1.2,-        genvalidity -any,+        validity >=0.4 && <0.5,+        validity-text >=0.2 && <0.3,+        genvalidity >=0.4 && <0.5,         text -any,         array -any,         QuickCheck -any@@ -37,7 +37,7 @@     build-depends:         base -any,         hspec -any,-        QuickCheck,+        QuickCheck -any,         genvalidity -any,         genvalidity-text -any,         genvalidity-hspec -any,
src/Data/GenValidity/Text.hs view
@@ -31,6 +31,7 @@             off <- upTo $ max 0 (size - 1)             let len = size - off             pure $ Text arr off len+    shrinkUnchecked _ = []  instance GenValid Text where     genValid =@@ -38,6 +39,7 @@             size <- upTo n             chars <- resize size $ genListOf arbitrary             return $ T.pack chars+    shrinkValid = fmap T.pack . shrinkValid . T.unpack  instance GenInvalid Text @@ -71,7 +73,7 @@ textWithoutAny c = textWithoutAnyOf [c]  -- | 'textWithoutAnyOf c' generates a 'Text' value that does not contain any character in 'ls'.-textWithoutAnyOf :: [Char] -> Gen Text+textWithoutAnyOf :: String -> Gen Text textWithoutAnyOf cs = T.pack <$> genListOf (arbitrary `suchThat` (`notElem` cs))  -- | 'textAllCaps' generates a 'Text' value with only upper-case characters.
test/Data/GenValidity/TextSpec.hs view
@@ -38,7 +38,7 @@ spec :: Spec spec = do     describe "genValid" $ do-        it "is always empty when resized to 0" $ do+        it "is always empty when resized to 0" $             forAll (resize 0 genValid) (`shouldSatisfy` T.null)         it "generates valid text" $             forAll (genValid :: Gen Text) $ \t ->@@ -48,31 +48,31 @@         forAll ((genUnchecked :: Gen Text) `suchThat` isValid) $ \t ->             unless (isValid t) $ expectationFailure $ showTextDebug t     describe "textStartingWith" $ do-        it "is never empty" $ do+        it "is never empty" $             forAll arbitrary $ \c ->                 forAll (textStartingWith c) $ \t -> t `shouldNotSatisfy` T.null-        it "contains exactly the first character if resized to 0" $ do+        it "contains exactly the first character if resized to 0" $             forAll arbitrary $ \c ->                 forAll (resize 0 $ textStartingWith c) $ \t ->                     t `shouldBe` T.pack [c]-        it "contains exactly the first character if resized to 1" $ do+        it "contains exactly the first character if resized to 1" $             forAll arbitrary $ \c ->                 forAll (resize 0 $ textStartingWith c) $ \t ->                     t `shouldBe` T.pack [c]-        it "always starts with the given char" $ do+        it "always starts with the given char" $             forAll arbitrary $ \c ->                 forAll (textStartingWith c) $ \t -> T.head t `shouldBe` c-    describe "textWithA" $ do-        it "contains the given character" $ do-            forAll arbitrary $ \c ->-                forAll (textWithA c) $ \t -> T.unpack t `shouldSatisfy` (elem c)-    describe "textWithoutAny" $ do-        it "never contains the given char" $ do-            forAll arbitrary $ \c ->-                forAll (textWithoutAny c) $ \t ->-                    T.unpack t `shouldNotSatisfy` (elem c)-    describe "textWithoutAnyOf" $ do-        it "never contains any of the given chars" $ do-            forAll arbitrary $ \cs ->-                forAll (textWithoutAnyOf cs) $ \text ->-                    T.unpack text `shouldNotSatisfy` (\t -> any (`elem` t) cs)+    describe "textWithA" $+        it "contains the given character" $+        forAll arbitrary $ \c ->+            forAll (textWithA c) $ \t -> T.unpack t `shouldSatisfy` elem c+    describe "textWithoutAny" $+        it "never contains the given char" $+        forAll arbitrary $ \c ->+            forAll (textWithoutAny c) $ \t ->+                T.unpack t `shouldNotSatisfy` elem c+    describe "textWithoutAnyOf" $+        it "never contains any of the given chars" $+        forAll arbitrary $ \cs ->+            forAll (textWithoutAnyOf cs) $ \text ->+                T.unpack text `shouldNotSatisfy` (\t -> any (`elem` t) cs)