{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE TypeApplications #-}
module Test.Syd.Validity.Arbitrary
( arbitrarySpec
, arbitraryGeneratesOnlyValid
) where
import Data.Data
import Data.GenValidity
import Test.Syd
import Test.QuickCheck
import Test.Syd.Validity.GenValidity
import Test.Syd.Validity.Utils
arbitrarySpec ::
forall a. (Typeable a, Show a, Validity a, Arbitrary a)
=> Spec
arbitrarySpec :: Spec
arbitrarySpec = do
let name :: String
name = Typeable a => String
forall k (a :: k). Typeable a => String
nameOf @a
String -> Spec -> Spec
forall (outers :: [*]) inner.
String -> TestDefM outers inner () -> TestDefM outers inner ()
describe (String
"Arbitrary " 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 (outers :: [*]) inner.
String -> TestDefM outers inner () -> TestDefM outers inner ()
describe (String
"arbitrary :: Gen " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
name) (Spec -> Spec) -> Spec -> Spec
forall a b. (a -> b) -> a -> b
$
String -> Property -> Spec
forall (outers :: [*]) inner test.
(HasCallStack, IsTest test, Arg1 test ~ (), Arg2 test ~ inner) =>
String -> test -> TestDefM outers inner ()
it String
"only generates valid values" (Property -> Spec) -> Property -> Spec
forall a b. (a -> b) -> a -> b
$ (Show a, Validity a, Arbitrary a) => Property
forall a. (Show a, Validity a, Arbitrary a) => Property
arbitraryGeneratesOnlyValid @a
arbitraryGeneratesOnlyValid ::
forall a. (Show a, Validity a, Arbitrary a)
=> Property
arbitraryGeneratesOnlyValid :: Property
arbitraryGeneratesOnlyValid = Gen a -> Property
forall a. (Show a, Validity a) => Gen a -> Property
genGeneratesValid @a Gen a
forall a. Arbitrary a => Gen a
arbitrary