{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
module Test.Validity.GenValidity
( genValidSpec,
genValidGeneratesValid,
genGeneratesValid,
genGeneratesInvalid,
)
where
import Data.Data
import Data.GenValidity
import Test.Hspec
import Test.QuickCheck
import Test.Validity.GenValidity.Property
import Test.Validity.Utils
genValidSpec ::
forall a.
(Typeable a, Show a, GenValid a) =>
Spec
genValidSpec :: Spec
genValidSpec =
Spec -> Spec
forall a. SpecWith a -> SpecWith a
parallel (Spec -> Spec) -> Spec -> Spec
forall a b. (a -> b) -> a -> b
$ do
let name :: String
name = Typeable a => String
forall k (a :: k). Typeable a => String
nameOf @a
String -> Spec -> Spec
forall a. HasCallStack => String -> SpecWith a -> SpecWith a
describe (String
"GenValid " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
name) (Spec -> Spec) -> Spec -> Spec
forall a b. (a -> b) -> a -> b
$
String -> Spec -> Spec
forall a. HasCallStack => String -> SpecWith a -> SpecWith a
describe (String
"genValid :: Gen " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
name) (Spec -> Spec) -> Spec -> Spec
forall a b. (a -> b) -> a -> b
$
String -> Property -> SpecWith (Arg Property)
forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
it (String
"only generates valid \'" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
name String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\'s") (Property -> SpecWith (Arg Property))
-> Property -> SpecWith (Arg Property)
forall a b. (a -> b) -> a -> b
$
(Show a, GenValid a) => Property
forall a. (Show a, GenValid a) => Property
genValidGeneratesValid @a
genValidGeneratesValid ::
forall a.
(Show a, GenValid a) =>
Property
genValidGeneratesValid :: Property
genValidGeneratesValid = Gen a -> Property
forall a. (Show a, Validity a) => Gen a -> Property
genGeneratesValid @a Gen a
forall a. GenValid a => Gen a
genValid