You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
712 B
23 lines
712 B
module Tests.Arbitrary.Common where |
|
|
|
import Control.Applicative ((<$>)) |
|
import Data.Char |
|
import qualified Data.Text as Text |
|
import Test.QuickCheck |
|
import Test.QuickCheck.Instances () |
|
|
|
shrinkText1 :: Text.Text -> [Text.Text] |
|
shrinkText1 txt = filter (not . Text.null) $ shrink txt |
|
|
|
shrinkTextMaybe :: Maybe Text.Text -> [Maybe Text.Text] |
|
shrinkTextMaybe mbtxt = filter (\mb -> mb /= Just (Text.empty)) $ shrink mbtxt |
|
|
|
genText1 :: Gen Text.Text |
|
genText1 = Text.pack <$> string1 |
|
where |
|
string1 = listOf1 arbitrary `suchThat` (not . all isSpace) |
|
|
|
maybeGen :: Gen a -> Gen (Maybe a) |
|
maybeGen g = oneof [ return Nothing |
|
, Just <$> g |
|
]
|
|
|