{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
module Test.Cardano.Chain.Update.Properties (
tests,
) where
import Cardano.Chain.Update (
ApplicationName (..),
ApplicationNameError (..),
SoftwareVersion (..),
SoftwareVersionError (..),
SystemTag (..),
SystemTagError (..),
applicationNameMaxLength,
checkApplicationName,
checkSoftwareVersion,
checkSystemTag,
systemTagMaxLength,
)
import Cardano.Prelude
import Data.Data (Constr, toConstr)
import qualified Data.Text as T
import Hedgehog (forAll, property)
import qualified Hedgehog.Gen as Gen
import qualified Hedgehog.Range as Range
import Test.Cardano.Chain.Update.Gen (
genApplicationName,
genSoftwareVersion,
genSystemTag,
)
import Test.Cardano.Prelude
import Test.Options (TSGroup, TSProperty, withTestsTS)
ts_prop_checkApplicationName :: TSProperty
ts_prop_checkApplicationName :: TSProperty
ts_prop_checkApplicationName = TestLimit -> Property -> TSProperty
withTestsTS TestLimit
100 (Property -> TSProperty)
-> (PropertyT IO () -> Property) -> PropertyT IO () -> TSProperty
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. HasCallStack => PropertyT IO () -> Property
PropertyT IO () -> Property
property (PropertyT IO () -> TSProperty) -> PropertyT IO () -> TSProperty
forall a b. (a -> b) -> a -> b
$ do
ApplicationName
aName <- Gen ApplicationName -> PropertyT IO ApplicationName
forall (m :: * -> *) a.
(Monad m, Show a, HasCallStack) =>
Gen a -> PropertyT m a
forAll Gen ApplicationName
genApplicationName
Either ApplicationNameError () -> PropertyT IO ()
forall a (m :: * -> *) b.
(Buildable a, HasCallStack, MonadTest m) =>
Either a b -> m ()
assertIsRight (Either ApplicationNameError () -> PropertyT IO ())
-> Either ApplicationNameError () -> PropertyT IO ()
forall a b. (a -> b) -> a -> b
$ ApplicationName -> Either ApplicationNameError ()
forall (m :: * -> *).
MonadError ApplicationNameError m =>
ApplicationName -> m ()
checkApplicationName ApplicationName
aName
ts_prop_checkApplicationNameTooLong :: TSProperty
ts_prop_checkApplicationNameTooLong :: TSProperty
ts_prop_checkApplicationNameTooLong = TestLimit -> Property -> TSProperty
withTestsTS TestLimit
100 (Property -> TSProperty)
-> (PropertyT IO () -> Property) -> PropertyT IO () -> TSProperty
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. HasCallStack => PropertyT IO () -> Property
PropertyT IO () -> Property
property (PropertyT IO () -> TSProperty) -> PropertyT IO () -> TSProperty
forall a b. (a -> b) -> a -> b
$ do
(ApplicationName Text
aName) <-
Gen ApplicationName -> PropertyT IO ApplicationName
forall (m :: * -> *) a.
(Monad m, Show a, HasCallStack) =>
Gen a -> PropertyT m a
forAll
(Gen ApplicationName -> PropertyT IO ApplicationName)
-> Gen ApplicationName -> PropertyT IO ApplicationName
forall a b. (a -> b) -> a -> b
$ (ApplicationName -> Bool)
-> Gen ApplicationName -> Gen ApplicationName
forall (m :: * -> *) a.
(MonadGen m, GenBase m ~ Identity) =>
(a -> Bool) -> m a -> m a
Gen.filter
(\ApplicationName
name -> Text -> Int
T.length (ApplicationName -> Text
unApplicationName ApplicationName
name) Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
forall i. Integral i => i
applicationNameMaxLength)
Gen ApplicationName
genApplicationName
Text
moreText <- Gen Text -> PropertyT IO Text
forall (m :: * -> *) a.
(Monad m, Show a, HasCallStack) =>
Gen a -> PropertyT m a
forAll (Gen Text -> PropertyT IO Text) -> Gen Text -> PropertyT IO Text
forall a b. (a -> b) -> a -> b
$ Range Int -> GenT Identity Char -> Gen Text
forall (m :: * -> *). MonadGen m => Range Int -> m Char -> m Text
Gen.text (Int -> Int -> Range Int
forall a. Integral a => a -> a -> Range a
Range.linear Int
1 Int
20) GenT Identity Char
forall (m :: * -> *). MonadGen m => m Char
Gen.ascii
Constr -> Either ApplicationNameError () -> PropertyT IO ()
forall b a (m :: * -> *).
(Buildable b, Data a, HasCallStack, MonadTest m) =>
Constr -> Either a b -> m ()
assertIsLeftConstr
Constr
dummyAppNameTooLong
(ApplicationName -> Either ApplicationNameError ()
forall (m :: * -> *).
MonadError ApplicationNameError m =>
ApplicationName -> m ()
checkApplicationName (ApplicationName -> Either ApplicationNameError ())
-> (Text -> ApplicationName)
-> Text
-> Either ApplicationNameError ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Text -> ApplicationName
ApplicationName (Text -> Either ApplicationNameError ())
-> Text -> Either ApplicationNameError ()
forall a b. (a -> b) -> a -> b
$ Text
aName Text -> Text -> Text
`T.append` Text
moreText)
ts_prop_checkApplicationNameNotAscii :: TSProperty
ts_prop_checkApplicationNameNotAscii :: TSProperty
ts_prop_checkApplicationNameNotAscii = TestLimit -> Property -> TSProperty
withTestsTS TestLimit
100 (Property -> TSProperty)
-> (PropertyT IO () -> Property) -> PropertyT IO () -> TSProperty
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. HasCallStack => PropertyT IO () -> Property
PropertyT IO () -> Property
property (PropertyT IO () -> TSProperty) -> PropertyT IO () -> TSProperty
forall a b. (a -> b) -> a -> b
$ do
String
nonAscii <-
Gen String -> PropertyT IO String
forall (m :: * -> *) a.
(Monad m, Show a, HasCallStack) =>
Gen a -> PropertyT m a
forAll
(Gen String -> PropertyT IO String)
-> Gen String -> PropertyT IO String
forall a b. (a -> b) -> a -> b
$ (String -> Bool) -> Gen String -> Gen String
forall (m :: * -> *) a.
(MonadGen m, GenBase m ~ Identity) =>
(a -> Bool) -> m a -> m a
Gen.filter
((Bool -> Bool) -> [Bool] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (Bool -> Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Bool
True) ([Bool] -> Bool) -> (String -> [Bool]) -> String -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. (Char -> Bool) -> String -> [Bool]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
map (Bool -> Bool
not (Bool -> Bool) -> (Char -> Bool) -> Char -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Char -> Bool
isAscii))
(Range Int -> GenT Identity Char -> Gen String
forall (m :: * -> *). MonadGen m => Range Int -> m Char -> m String
Gen.string (Int -> Int -> Range Int
forall a. Integral a => a -> a -> Range a
Range.linear Int
1 Int
forall i. Integral i => i
applicationNameMaxLength) GenT Identity Char
forall (m :: * -> *). MonadGen m => m Char
Gen.unicodeAll)
Constr -> Either ApplicationNameError () -> PropertyT IO ()
forall b a (m :: * -> *).
(Buildable b, Data a, HasCallStack, MonadTest m) =>
Constr -> Either a b -> m ()
assertIsLeftConstr
Constr
dummyAppNameNotAscii
(ApplicationName -> Either ApplicationNameError ()
forall (m :: * -> *).
MonadError ApplicationNameError m =>
ApplicationName -> m ()
checkApplicationName (ApplicationName -> Either ApplicationNameError ())
-> ApplicationName -> Either ApplicationNameError ()
forall a b. (a -> b) -> a -> b
$ Text -> ApplicationName
ApplicationName (Text -> ApplicationName) -> Text -> ApplicationName
forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack String
nonAscii)
ts_prop_checkSoftwareVersion :: TSProperty
ts_prop_checkSoftwareVersion :: TSProperty
ts_prop_checkSoftwareVersion = TestLimit -> Property -> TSProperty
withTestsTS TestLimit
100 (Property -> TSProperty)
-> (PropertyT IO () -> Property) -> PropertyT IO () -> TSProperty
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. HasCallStack => PropertyT IO () -> Property
PropertyT IO () -> Property
property (PropertyT IO () -> TSProperty) -> PropertyT IO () -> TSProperty
forall a b. (a -> b) -> a -> b
$ do
SoftwareVersion
sVer <- Gen SoftwareVersion -> PropertyT IO SoftwareVersion
forall (m :: * -> *) a.
(Monad m, Show a, HasCallStack) =>
Gen a -> PropertyT m a
forAll Gen SoftwareVersion
genSoftwareVersion
Either SoftwareVersionError () -> PropertyT IO ()
forall a (m :: * -> *) b.
(Buildable a, HasCallStack, MonadTest m) =>
Either a b -> m ()
assertIsRight (Either SoftwareVersionError () -> PropertyT IO ())
-> Either SoftwareVersionError () -> PropertyT IO ()
forall a b. (a -> b) -> a -> b
$ SoftwareVersion -> Either SoftwareVersionError ()
forall (m :: * -> *).
MonadError SoftwareVersionError m =>
SoftwareVersion -> m ()
checkSoftwareVersion SoftwareVersion
sVer
ts_prop_checkSoftwareVersionTooLong :: TSProperty
ts_prop_checkSoftwareVersionTooLong :: TSProperty
ts_prop_checkSoftwareVersionTooLong = TestLimit -> Property -> TSProperty
withTestsTS TestLimit
100 (Property -> TSProperty)
-> (PropertyT IO () -> Property) -> PropertyT IO () -> TSProperty
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. HasCallStack => PropertyT IO () -> Property
PropertyT IO () -> Property
property (PropertyT IO () -> TSProperty) -> PropertyT IO () -> TSProperty
forall a b. (a -> b) -> a -> b
$ do
(ApplicationName Text
aName) <-
Gen ApplicationName -> PropertyT IO ApplicationName
forall (m :: * -> *) a.
(Monad m, Show a, HasCallStack) =>
Gen a -> PropertyT m a
forAll
(Gen ApplicationName -> PropertyT IO ApplicationName)
-> Gen ApplicationName -> PropertyT IO ApplicationName
forall a b. (a -> b) -> a -> b
$ (ApplicationName -> Bool)
-> Gen ApplicationName -> Gen ApplicationName
forall (m :: * -> *) a.
(MonadGen m, GenBase m ~ Identity) =>
(a -> Bool) -> m a -> m a
Gen.filter
(\ApplicationName
name -> Text -> Int
T.length (ApplicationName -> Text
unApplicationName ApplicationName
name) Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
forall i. Integral i => i
applicationNameMaxLength)
Gen ApplicationName
genApplicationName
Text
moreText <- Gen Text -> PropertyT IO Text
forall (m :: * -> *) a.
(Monad m, Show a, HasCallStack) =>
Gen a -> PropertyT m a
forAll (Gen Text -> PropertyT IO Text) -> Gen Text -> PropertyT IO Text
forall a b. (a -> b) -> a -> b
$ Range Int -> GenT Identity Char -> Gen Text
forall (m :: * -> *). MonadGen m => Range Int -> m Char -> m Text
Gen.text (Int -> Int -> Range Int
forall a. Integral a => a -> a -> Range a
Range.linear Int
1 Int
20) GenT Identity Char
forall (m :: * -> *). MonadGen m => m Char
Gen.ascii
let appNameTooLong :: ApplicationName
appNameTooLong = Text -> ApplicationName
ApplicationName (Text -> ApplicationName) -> Text -> ApplicationName
forall a b. (a -> b) -> a -> b
$ Text
aName Text -> Text -> Text
`T.append` Text
moreText
SoftwareVersion
sVersion <- Gen SoftwareVersion -> PropertyT IO SoftwareVersion
forall (m :: * -> *) a.
(Monad m, Show a, HasCallStack) =>
Gen a -> PropertyT m a
forAll Gen SoftwareVersion
genSoftwareVersion
let sVersion' :: SoftwareVersion
sVersion' = SoftwareVersion
sVersion {svAppName = appNameTooLong}
Constr -> Either SoftwareVersionError () -> PropertyT IO ()
forall b a (m :: * -> *).
(Buildable b, Data a, HasCallStack, MonadTest m) =>
Constr -> Either a b -> m ()
assertIsLeftConstr Constr
dummySoftVerTooLong (SoftwareVersion -> Either SoftwareVersionError ()
forall (m :: * -> *).
MonadError SoftwareVersionError m =>
SoftwareVersion -> m ()
checkSoftwareVersion SoftwareVersion
sVersion')
ts_prop_checkSoftwareVersionNotAscii :: TSProperty
ts_prop_checkSoftwareVersionNotAscii :: TSProperty
ts_prop_checkSoftwareVersionNotAscii = TestLimit -> Property -> TSProperty
withTestsTS TestLimit
100 (Property -> TSProperty)
-> (PropertyT IO () -> Property) -> PropertyT IO () -> TSProperty
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. HasCallStack => PropertyT IO () -> Property
PropertyT IO () -> Property
property (PropertyT IO () -> TSProperty) -> PropertyT IO () -> TSProperty
forall a b. (a -> b) -> a -> b
$ do
String
nonAscii <-
Gen String -> PropertyT IO String
forall (m :: * -> *) a.
(Monad m, Show a, HasCallStack) =>
Gen a -> PropertyT m a
forAll
(Gen String -> PropertyT IO String)
-> Gen String -> PropertyT IO String
forall a b. (a -> b) -> a -> b
$ (String -> Bool) -> Gen String -> Gen String
forall (m :: * -> *) a.
(MonadGen m, GenBase m ~ Identity) =>
(a -> Bool) -> m a -> m a
Gen.filter
((Bool -> Bool) -> [Bool] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (Bool -> Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Bool
True) ([Bool] -> Bool) -> (String -> [Bool]) -> String -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. (Char -> Bool) -> String -> [Bool]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
map (Bool -> Bool
not (Bool -> Bool) -> (Char -> Bool) -> Char -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Char -> Bool
isAscii))
(Range Int -> GenT Identity Char -> Gen String
forall (m :: * -> *). MonadGen m => Range Int -> m Char -> m String
Gen.string (Int -> Int -> Range Int
forall a. Integral a => a -> a -> Range a
Range.linear Int
1 Int
forall i. Integral i => i
applicationNameMaxLength) GenT Identity Char
forall (m :: * -> *). MonadGen m => m Char
Gen.unicodeAll)
let appNameNonascii :: ApplicationName
appNameNonascii = Text -> ApplicationName
ApplicationName (Text -> ApplicationName) -> Text -> ApplicationName
forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack String
nonAscii
SoftwareVersion
sVersion <- Gen SoftwareVersion -> PropertyT IO SoftwareVersion
forall (m :: * -> *) a.
(Monad m, Show a, HasCallStack) =>
Gen a -> PropertyT m a
forAll Gen SoftwareVersion
genSoftwareVersion
let sVersion' :: SoftwareVersion
sVersion' = SoftwareVersion
sVersion {svAppName = appNameNonascii}
Constr -> Either SoftwareVersionError () -> PropertyT IO ()
forall b a (m :: * -> *).
(Buildable b, Data a, HasCallStack, MonadTest m) =>
Constr -> Either a b -> m ()
assertIsLeftConstr Constr
dummySoftVerNotAscii (SoftwareVersion -> Either SoftwareVersionError ()
forall (m :: * -> *).
MonadError SoftwareVersionError m =>
SoftwareVersion -> m ()
checkSoftwareVersion SoftwareVersion
sVersion')
ts_prop_checkSystemTag :: TSProperty
ts_prop_checkSystemTag :: TSProperty
ts_prop_checkSystemTag = TestLimit -> Property -> TSProperty
withTestsTS TestLimit
100 (Property -> TSProperty)
-> (PropertyT IO () -> Property) -> PropertyT IO () -> TSProperty
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. HasCallStack => PropertyT IO () -> Property
PropertyT IO () -> Property
property (PropertyT IO () -> TSProperty) -> PropertyT IO () -> TSProperty
forall a b. (a -> b) -> a -> b
$ do
SystemTag
sTag <- Gen SystemTag -> PropertyT IO SystemTag
forall (m :: * -> *) a.
(Monad m, Show a, HasCallStack) =>
Gen a -> PropertyT m a
forAll Gen SystemTag
genSystemTag
Either SystemTagError () -> PropertyT IO ()
forall a (m :: * -> *) b.
(Buildable a, HasCallStack, MonadTest m) =>
Either a b -> m ()
assertIsRight (Either SystemTagError () -> PropertyT IO ())
-> Either SystemTagError () -> PropertyT IO ()
forall a b. (a -> b) -> a -> b
$ SystemTag -> Either SystemTagError ()
forall (m :: * -> *).
MonadError SystemTagError m =>
SystemTag -> m ()
checkSystemTag SystemTag
sTag
ts_prop_checkSystemTagTooLong :: TSProperty
ts_prop_checkSystemTagTooLong :: TSProperty
ts_prop_checkSystemTagTooLong = TestLimit -> Property -> TSProperty
withTestsTS TestLimit
100 (Property -> TSProperty)
-> (PropertyT IO () -> Property) -> PropertyT IO () -> TSProperty
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. HasCallStack => PropertyT IO () -> Property
PropertyT IO () -> Property
property (PropertyT IO () -> TSProperty) -> PropertyT IO () -> TSProperty
forall a b. (a -> b) -> a -> b
$ do
(SystemTag Text
tag) <-
Gen SystemTag -> PropertyT IO SystemTag
forall (m :: * -> *) a.
(Monad m, Show a, HasCallStack) =>
Gen a -> PropertyT m a
forAll
(Gen SystemTag -> PropertyT IO SystemTag)
-> Gen SystemTag -> PropertyT IO SystemTag
forall a b. (a -> b) -> a -> b
$ (SystemTag -> Bool) -> Gen SystemTag -> Gen SystemTag
forall (m :: * -> *) a.
(MonadGen m, GenBase m ~ Identity) =>
(a -> Bool) -> m a -> m a
Gen.filter
(\SystemTag
sysTag -> Text -> Int
T.length (SystemTag -> Text
getSystemTag SystemTag
sysTag) Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
forall i. Integral i => i
systemTagMaxLength)
Gen SystemTag
genSystemTag
Text
moreText <- Gen Text -> PropertyT IO Text
forall (m :: * -> *) a.
(Monad m, Show a, HasCallStack) =>
Gen a -> PropertyT m a
forAll (Gen Text -> PropertyT IO Text) -> Gen Text -> PropertyT IO Text
forall a b. (a -> b) -> a -> b
$ Range Int -> GenT Identity Char -> Gen Text
forall (m :: * -> *). MonadGen m => Range Int -> m Char -> m Text
Gen.text (Int -> Int -> Range Int
forall a. Integral a => a -> a -> Range a
Range.linear Int
1 Int
20) GenT Identity Char
forall (m :: * -> *). MonadGen m => m Char
Gen.ascii
let sysTagTooLong :: SystemTag
sysTagTooLong = Text -> SystemTag
SystemTag (Text
tag Text -> Text -> Text
`T.append` Text
moreText)
Constr -> Either SystemTagError () -> PropertyT IO ()
forall b a (m :: * -> *).
(Buildable b, Data a, HasCallStack, MonadTest m) =>
Constr -> Either a b -> m ()
assertIsLeftConstr Constr
dummySysTagTooLong (SystemTag -> Either SystemTagError ()
forall (m :: * -> *).
MonadError SystemTagError m =>
SystemTag -> m ()
checkSystemTag SystemTag
sysTagTooLong)
ts_prop_checkSystemTagNotAscii :: TSProperty
ts_prop_checkSystemTagNotAscii :: TSProperty
ts_prop_checkSystemTagNotAscii = TestLimit -> Property -> TSProperty
withTestsTS TestLimit
100 (Property -> TSProperty)
-> (PropertyT IO () -> Property) -> PropertyT IO () -> TSProperty
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. HasCallStack => PropertyT IO () -> Property
PropertyT IO () -> Property
property (PropertyT IO () -> TSProperty) -> PropertyT IO () -> TSProperty
forall a b. (a -> b) -> a -> b
$ do
String
nonAscii <-
Gen String -> PropertyT IO String
forall (m :: * -> *) a.
(Monad m, Show a, HasCallStack) =>
Gen a -> PropertyT m a
forAll
(Gen String -> PropertyT IO String)
-> Gen String -> PropertyT IO String
forall a b. (a -> b) -> a -> b
$ (String -> Bool) -> Gen String -> Gen String
forall (m :: * -> *) a.
(MonadGen m, GenBase m ~ Identity) =>
(a -> Bool) -> m a -> m a
Gen.filter
((Bool -> Bool) -> [Bool] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (Bool -> Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Bool
True) ([Bool] -> Bool) -> (String -> [Bool]) -> String -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. (Char -> Bool) -> String -> [Bool]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
map (Bool -> Bool
not (Bool -> Bool) -> (Char -> Bool) -> Char -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Char -> Bool
isAscii))
(Range Int -> GenT Identity Char -> Gen String
forall (m :: * -> *). MonadGen m => Range Int -> m Char -> m String
Gen.string (Int -> Int -> Range Int
forall a. Integral a => a -> a -> Range a
Range.linear Int
1 Int
forall i. Integral i => i
systemTagMaxLength) GenT Identity Char
forall (m :: * -> *). MonadGen m => m Char
Gen.unicodeAll)
let sysTagNonascii :: SystemTag
sysTagNonascii = Text -> SystemTag
SystemTag (Text -> SystemTag) -> Text -> SystemTag
forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack String
nonAscii
Constr -> Either SystemTagError () -> PropertyT IO ()
forall b a (m :: * -> *).
(Buildable b, Data a, HasCallStack, MonadTest m) =>
Constr -> Either a b -> m ()
assertIsLeftConstr Constr
dummySysTagNotAscii (SystemTag -> Either SystemTagError ()
forall (m :: * -> *).
MonadError SystemTagError m =>
SystemTag -> m ()
checkSystemTag SystemTag
sysTagNonascii)
tests :: TSGroup
tests :: TSGroup
tests = $$discoverPropArg
dummyAppNameNotAscii :: Constr
dummyAppNameNotAscii :: Constr
dummyAppNameNotAscii = ApplicationNameError -> Constr
forall a. Data a => a -> Constr
toConstr (ApplicationNameError -> Constr) -> ApplicationNameError -> Constr
forall a b. (a -> b) -> a -> b
$ Text -> ApplicationNameError
ApplicationNameNotAscii Text
"dummyValue"
dummyAppNameTooLong :: Constr
dummyAppNameTooLong :: Constr
dummyAppNameTooLong = ApplicationNameError -> Constr
forall a. Data a => a -> Constr
toConstr (ApplicationNameError -> Constr) -> ApplicationNameError -> Constr
forall a b. (a -> b) -> a -> b
$ Text -> ApplicationNameError
ApplicationNameTooLong Text
"dummyValue"
dummySoftVerNotAscii :: Constr
dummySoftVerNotAscii :: Constr
dummySoftVerNotAscii =
SoftwareVersionError -> Constr
forall a. Data a => a -> Constr
toConstr
(SoftwareVersionError -> Constr)
-> (ApplicationNameError -> SoftwareVersionError)
-> ApplicationNameError
-> Constr
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. ApplicationNameError -> SoftwareVersionError
SoftwareVersionApplicationNameError
(ApplicationNameError -> Constr) -> ApplicationNameError -> Constr
forall a b. (a -> b) -> a -> b
$ Text -> ApplicationNameError
ApplicationNameNotAscii
Text
"dummyValue"
dummySoftVerTooLong :: Constr
dummySoftVerTooLong :: Constr
dummySoftVerTooLong =
SoftwareVersionError -> Constr
forall a. Data a => a -> Constr
toConstr
(SoftwareVersionError -> Constr)
-> (ApplicationNameError -> SoftwareVersionError)
-> ApplicationNameError
-> Constr
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. ApplicationNameError -> SoftwareVersionError
SoftwareVersionApplicationNameError
(ApplicationNameError -> Constr) -> ApplicationNameError -> Constr
forall a b. (a -> b) -> a -> b
$ Text -> ApplicationNameError
ApplicationNameTooLong
Text
"dummyValue"
dummySysTagNotAscii :: Constr
dummySysTagNotAscii :: Constr
dummySysTagNotAscii = SystemTagError -> Constr
forall a. Data a => a -> Constr
toConstr (SystemTagError -> Constr) -> SystemTagError -> Constr
forall a b. (a -> b) -> a -> b
$ Text -> SystemTagError
SystemTagNotAscii Text
"dummyValue"
dummySysTagTooLong :: Constr
dummySysTagTooLong :: Constr
dummySysTagTooLong = SystemTagError -> Constr
forall a. Data a => a -> Constr
toConstr (SystemTagError -> Constr) -> SystemTagError -> Constr
forall a b. (a -> b) -> a -> b
$ Text -> SystemTagError
SystemTagTooLong Text
"dummyValue"