-- A type of test case generators.
{-# OPTIONS_HADDOCK hide #-}
{-# LANGUAGE FunctionalDependencies, DefaultSignatures, GADTs, FlexibleInstances, UndecidableInstances, TypeOperators, DeriveFunctor #-}
module QuickSpec.Internal.Testing where

import QuickSpec.Internal.Prop
import Control.Monad.Trans.Class
import Control.Monad.Trans.State.Strict
import Control.Monad.Trans.Reader

data TestResult testcase =
    TestPassed
  | TestFailed testcase
  | Untestable
  deriving (forall a b. a -> TestResult b -> TestResult a
forall a b. (a -> b) -> TestResult a -> TestResult b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> TestResult b -> TestResult a
$c<$ :: forall a b. a -> TestResult b -> TestResult a
fmap :: forall a b. (a -> b) -> TestResult a -> TestResult b
$cfmap :: forall a b. (a -> b) -> TestResult a -> TestResult b
Functor, TestResult testcase -> TestResult testcase -> Bool
forall testcase.
Eq testcase =>
TestResult testcase -> TestResult testcase -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestResult testcase -> TestResult testcase -> Bool
$c/= :: forall testcase.
Eq testcase =>
TestResult testcase -> TestResult testcase -> Bool
== :: TestResult testcase -> TestResult testcase -> Bool
$c== :: forall testcase.
Eq testcase =>
TestResult testcase -> TestResult testcase -> Bool
Eq)

testResult :: TestResult testcase -> TestResult ()
testResult :: forall testcase. TestResult testcase -> TestResult ()
testResult = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall a b. a -> b -> a
const ())

testAnd :: TestResult testcase -> TestResult testcase -> TestResult testcase
TestResult testcase
TestPassed testAnd :: forall testcase.
TestResult testcase -> TestResult testcase -> TestResult testcase
`testAnd` TestResult testcase
x = TestResult testcase
x
TestResult testcase
x `testAnd` TestResult testcase
_ = TestResult testcase
x

testImplies :: TestResult testcase -> TestResult testcase -> TestResult testcase
TestResult testcase
TestPassed testImplies :: forall testcase.
TestResult testcase -> TestResult testcase -> TestResult testcase
`testImplies` TestResult testcase
x = TestResult testcase
x
TestFailed testcase
_ `testImplies` TestResult testcase
_ = forall testcase. TestResult testcase
TestPassed
TestResult testcase
Untestable `testImplies` TestResult testcase
_ = forall testcase. TestResult testcase
Untestable

class Monad m => MonadTester testcase term m | m -> testcase term where
  test :: Prop term -> m (TestResult testcase)
  retest :: testcase -> Prop term -> m (TestResult testcase)

  default test :: (MonadTrans t, MonadTester testcase term m', m ~ t m') => Prop term -> m (TestResult testcase)
  test = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall testcase term (m :: * -> *).
MonadTester testcase term m =>
Prop term -> m (TestResult testcase)
test

  default retest :: (MonadTrans t, MonadTester testcase term m', m ~ t m') => testcase -> Prop term -> m (TestResult testcase)
  retest testcase
tc = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall testcase term (m :: * -> *).
MonadTester testcase term m =>
testcase -> Prop term -> m (TestResult testcase)
retest testcase
tc

instance MonadTester testcase term m => MonadTester testcase term (StateT s m)
instance MonadTester testcase term m => MonadTester testcase term (ReaderT r m)