{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE CPP #-}

-- | The core Spec/SpecCommand types, used to define the test free monad.

module Test.Sandwich.Types.Spec where

import Control.Exception.Safe
import Control.Monad.Base
import Control.Monad.Except
import Control.Monad.Free
import Control.Monad.Free.TH
import Control.Monad.IO.Unlift
import Control.Monad.Logger
import Control.Monad.Reader
import Control.Monad.Trans.Control
import Data.Functor.Classes
import Data.Maybe
import Data.String.Interpolate
import GHC.Stack
import GHC.TypeLits
import Safe

#ifndef mingw32_HOST_OS
import Graphics.Vty.Image (Image)
#endif

#if !MIN_VERSION_base(4,13,0)
import Control.Monad.Fail
#endif


-- * ExampleM monad

newtype ExampleT context m a = ExampleT { forall context (m :: * -> *) a.
ExampleT context m a -> ReaderT context (LoggingT m) a
unExampleT :: ReaderT context (LoggingT m) a }
  deriving (forall a b. a -> ExampleT context m b -> ExampleT context m a
forall a b.
(a -> b) -> ExampleT context m a -> ExampleT context m b
forall context (m :: * -> *) a b.
Functor m =>
a -> ExampleT context m b -> ExampleT context m a
forall context (m :: * -> *) a b.
Functor m =>
(a -> b) -> ExampleT context m a -> ExampleT context m 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 -> ExampleT context m b -> ExampleT context m a
$c<$ :: forall context (m :: * -> *) a b.
Functor m =>
a -> ExampleT context m b -> ExampleT context m a
fmap :: forall a b.
(a -> b) -> ExampleT context m a -> ExampleT context m b
$cfmap :: forall context (m :: * -> *) a b.
Functor m =>
(a -> b) -> ExampleT context m a -> ExampleT context m b
Functor, forall a. a -> ExampleT context m a
forall a b.
ExampleT context m a
-> ExampleT context m b -> ExampleT context m a
forall a b.
ExampleT context m a
-> ExampleT context m b -> ExampleT context m b
forall a b.
ExampleT context m (a -> b)
-> ExampleT context m a -> ExampleT context m b
forall a b c.
(a -> b -> c)
-> ExampleT context m a
-> ExampleT context m b
-> ExampleT context m c
forall {context} {m :: * -> *}.
Applicative m =>
Functor (ExampleT context m)
forall context (m :: * -> *) a.
Applicative m =>
a -> ExampleT context m a
forall context (m :: * -> *) a b.
Applicative m =>
ExampleT context m a
-> ExampleT context m b -> ExampleT context m a
forall context (m :: * -> *) a b.
Applicative m =>
ExampleT context m a
-> ExampleT context m b -> ExampleT context m b
forall context (m :: * -> *) a b.
Applicative m =>
ExampleT context m (a -> b)
-> ExampleT context m a -> ExampleT context m b
forall context (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> ExampleT context m a
-> ExampleT context m b
-> ExampleT context m c
forall (f :: * -> *).
Functor f
-> (forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
<* :: forall a b.
ExampleT context m a
-> ExampleT context m b -> ExampleT context m a
$c<* :: forall context (m :: * -> *) a b.
Applicative m =>
ExampleT context m a
-> ExampleT context m b -> ExampleT context m a
*> :: forall a b.
ExampleT context m a
-> ExampleT context m b -> ExampleT context m b
$c*> :: forall context (m :: * -> *) a b.
Applicative m =>
ExampleT context m a
-> ExampleT context m b -> ExampleT context m b
liftA2 :: forall a b c.
(a -> b -> c)
-> ExampleT context m a
-> ExampleT context m b
-> ExampleT context m c
$cliftA2 :: forall context (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> ExampleT context m a
-> ExampleT context m b
-> ExampleT context m c
<*> :: forall a b.
ExampleT context m (a -> b)
-> ExampleT context m a -> ExampleT context m b
$c<*> :: forall context (m :: * -> *) a b.
Applicative m =>
ExampleT context m (a -> b)
-> ExampleT context m a -> ExampleT context m b
pure :: forall a. a -> ExampleT context m a
$cpure :: forall context (m :: * -> *) a.
Applicative m =>
a -> ExampleT context m a
Applicative, forall a. a -> ExampleT context m a
forall a b.
ExampleT context m a
-> ExampleT context m b -> ExampleT context m b
forall a b.
ExampleT context m a
-> (a -> ExampleT context m b) -> ExampleT context m b
forall {context} {m :: * -> *}.
Monad m =>
Applicative (ExampleT context m)
forall context (m :: * -> *) a.
Monad m =>
a -> ExampleT context m a
forall context (m :: * -> *) a b.
Monad m =>
ExampleT context m a
-> ExampleT context m b -> ExampleT context m b
forall context (m :: * -> *) a b.
Monad m =>
ExampleT context m a
-> (a -> ExampleT context m b) -> ExampleT context m b
forall (m :: * -> *).
Applicative m
-> (forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
return :: forall a. a -> ExampleT context m a
$creturn :: forall context (m :: * -> *) a.
Monad m =>
a -> ExampleT context m a
>> :: forall a b.
ExampleT context m a
-> ExampleT context m b -> ExampleT context m b
$c>> :: forall context (m :: * -> *) a b.
Monad m =>
ExampleT context m a
-> ExampleT context m b -> ExampleT context m b
>>= :: forall a b.
ExampleT context m a
-> (a -> ExampleT context m b) -> ExampleT context m b
$c>>= :: forall context (m :: * -> *) a b.
Monad m =>
ExampleT context m a
-> (a -> ExampleT context m b) -> ExampleT context m b
Monad, forall a. IO a -> ExampleT context m a
forall {context} {m :: * -> *}.
MonadIO m =>
Monad (ExampleT context m)
forall context (m :: * -> *) a.
MonadIO m =>
IO a -> ExampleT context m a
forall (m :: * -> *).
Monad m -> (forall a. IO a -> m a) -> MonadIO m
liftIO :: forall a. IO a -> ExampleT context m a
$cliftIO :: forall context (m :: * -> *) a.
MonadIO m =>
IO a -> ExampleT context m a
MonadIO, MonadReader context, forall msg.
ToLogStr msg =>
Loc -> LogSource -> LogLevel -> msg -> ExampleT context m ()
forall {context} {m :: * -> *}.
MonadIO m =>
Monad (ExampleT context m)
forall context (m :: * -> *) msg.
(MonadIO m, ToLogStr msg) =>
Loc -> LogSource -> LogLevel -> msg -> ExampleT context m ()
forall (m :: * -> *).
Monad m
-> (forall msg.
    ToLogStr msg =>
    Loc -> LogSource -> LogLevel -> msg -> m ())
-> MonadLogger m
monadLoggerLog :: forall msg.
ToLogStr msg =>
Loc -> LogSource -> LogLevel -> msg -> ExampleT context m ()
$cmonadLoggerLog :: forall context (m :: * -> *) msg.
(MonadIO m, ToLogStr msg) =>
Loc -> LogSource -> LogLevel -> msg -> ExampleT context m ()
MonadLogger, ExampleT
  context m (Loc -> LogSource -> LogLevel -> LogStr -> IO ())
forall context (m :: * -> *).
MonadIO m =>
MonadIO (ExampleT context m)
forall context (m :: * -> *).
MonadIO m =>
MonadLogger (ExampleT context m)
forall context (m :: * -> *).
MonadIO m =>
ExampleT
  context m (Loc -> LogSource -> LogLevel -> LogStr -> IO ())
forall (m :: * -> *).
MonadLogger m
-> MonadIO m
-> m (Loc -> LogSource -> LogLevel -> LogStr -> IO ())
-> MonadLoggerIO m
askLoggerIO :: ExampleT
  context m (Loc -> LogSource -> LogLevel -> LogStr -> IO ())
$caskLoggerIO :: forall context (m :: * -> *).
MonadIO m =>
ExampleT
  context m (Loc -> LogSource -> LogLevel -> LogStr -> IO ())
MonadLoggerIO, forall e a. Exception e => e -> ExampleT context m a
forall {context} {m :: * -> *}.
MonadThrow m =>
Monad (ExampleT context m)
forall context (m :: * -> *) e a.
(MonadThrow m, Exception e) =>
e -> ExampleT context m a
forall (m :: * -> *).
Monad m -> (forall e a. Exception e => e -> m a) -> MonadThrow m
throwM :: forall e a. Exception e => e -> ExampleT context m a
$cthrowM :: forall context (m :: * -> *) e a.
(MonadThrow m, Exception e) =>
e -> ExampleT context m a
MonadThrow, forall e a.
Exception e =>
ExampleT context m a
-> (e -> ExampleT context m a) -> ExampleT context m a
forall {context} {m :: * -> *}.
MonadCatch m =>
MonadThrow (ExampleT context m)
forall context (m :: * -> *) e a.
(MonadCatch m, Exception e) =>
ExampleT context m a
-> (e -> ExampleT context m a) -> ExampleT context m a
forall (m :: * -> *).
MonadThrow m
-> (forall e a. Exception e => m a -> (e -> m a) -> m a)
-> MonadCatch m
catch :: forall e a.
Exception e =>
ExampleT context m a
-> (e -> ExampleT context m a) -> ExampleT context m a
$ccatch :: forall context (m :: * -> *) e a.
(MonadCatch m, Exception e) =>
ExampleT context m a
-> (e -> ExampleT context m a) -> ExampleT context m a
MonadCatch, forall b.
((forall a. ExampleT context m a -> ExampleT context m a)
 -> ExampleT context m b)
-> ExampleT context m b
forall a b c.
ExampleT context m a
-> (a -> ExitCase b -> ExampleT context m c)
-> (a -> ExampleT context m b)
-> ExampleT context m (b, c)
forall {context} {m :: * -> *}.
MonadMask m =>
MonadCatch (ExampleT context m)
forall context (m :: * -> *) b.
MonadMask m =>
((forall a. ExampleT context m a -> ExampleT context m a)
 -> ExampleT context m b)
-> ExampleT context m b
forall context (m :: * -> *) a b c.
MonadMask m =>
ExampleT context m a
-> (a -> ExitCase b -> ExampleT context m c)
-> (a -> ExampleT context m b)
-> ExampleT context m (b, c)
forall (m :: * -> *).
MonadCatch m
-> (forall b. ((forall a. m a -> m a) -> m b) -> m b)
-> (forall b. ((forall a. m a -> m a) -> m b) -> m b)
-> (forall a b c.
    m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c))
-> MonadMask m
generalBracket :: forall a b c.
ExampleT context m a
-> (a -> ExitCase b -> ExampleT context m c)
-> (a -> ExampleT context m b)
-> ExampleT context m (b, c)
$cgeneralBracket :: forall context (m :: * -> *) a b c.
MonadMask m =>
ExampleT context m a
-> (a -> ExitCase b -> ExampleT context m c)
-> (a -> ExampleT context m b)
-> ExampleT context m (b, c)
uninterruptibleMask :: forall b.
((forall a. ExampleT context m a -> ExampleT context m a)
 -> ExampleT context m b)
-> ExampleT context m b
$cuninterruptibleMask :: forall context (m :: * -> *) b.
MonadMask m =>
((forall a. ExampleT context m a -> ExampleT context m a)
 -> ExampleT context m b)
-> ExampleT context m b
mask :: forall b.
((forall a. ExampleT context m a -> ExampleT context m a)
 -> ExampleT context m b)
-> ExampleT context m b
$cmask :: forall context (m :: * -> *) b.
MonadMask m =>
((forall a. ExampleT context m a -> ExampleT context m a)
 -> ExampleT context m b)
-> ExampleT context m b
MonadMask)
type ExampleM context = ExampleT context IO

instance (MonadIO m, MonadUnliftIO m) => MonadUnliftIO (ExampleT context m) where
  withRunInIO :: forall b.
((forall a. ExampleT context m a -> IO a) -> IO b)
-> ExampleT context m b
withRunInIO (forall a. ExampleT context m a -> IO a) -> IO b
inner = forall context (m :: * -> *) a.
ReaderT context (LoggingT m) a -> ExampleT context m a
ExampleT forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO forall a b. (a -> b) -> a -> b
$ \forall a. ReaderT context (LoggingT m) a -> IO a
run -> (forall a. ExampleT context m a -> IO a) -> IO b
inner (forall a. ReaderT context (LoggingT m) a -> IO a
run forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall context (m :: * -> *) a.
ExampleT context m a -> ReaderT context (LoggingT m) a
unExampleT)

instance (MonadBase b m) => MonadBase b (ExampleT context m) where
  liftBase :: forall α. b α -> ExampleT context m α
liftBase = forall (t :: (* -> *) -> * -> *) (b :: * -> *) (m :: * -> *) α.
(MonadTrans t, MonadBase b m) =>
b α -> t m α
liftBaseDefault

instance MonadTrans (ExampleT context) where
  lift :: forall (m :: * -> *) a. Monad m => m a -> ExampleT context m a
lift m a
x = forall context (m :: * -> *) a.
ReaderT context (LoggingT m) a -> ExampleT context m a
ExampleT forall a b. (a -> b) -> a -> b
$ forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT (\context
_ -> (forall (m :: * -> *) a.
((Loc -> LogSource -> LogLevel -> LogStr -> IO ()) -> m a)
-> LoggingT m a
LoggingT (\Loc -> LogSource -> LogLevel -> LogStr -> IO ()
_ -> m a
x)))

instance MonadTransControl (ExampleT context) where
  type StT (ExampleT context) a = StT LoggingT (StT (ReaderT context) a)
  liftWith :: forall (m :: * -> *) a.
Monad m =>
(Run (ExampleT context) -> m a) -> ExampleT context m a
liftWith Run (ExampleT context) -> m a
f = forall (m :: * -> *) (n' :: (* -> *) -> * -> *)
       (n :: (* -> *) -> * -> *) (t :: (* -> *) -> * -> *) a.
(Monad m, Monad (n' m), MonadTransControl n,
 MonadTransControl n') =>
(forall b. n (n' m) b -> t m b)
-> (forall (o :: * -> *) b. t o b -> n (n' o) b)
-> (RunDefault2 t n n' -> m a)
-> t m a
defaultLiftWith2 forall context (m :: * -> *) a.
ReaderT context (LoggingT m) a -> ExampleT context m a
ExampleT forall context (m :: * -> *) a.
ExampleT context m a -> ReaderT context (LoggingT m) a
unExampleT forall a b. (a -> b) -> a -> b
$ \RunDefault2 (ExampleT context) (ReaderT context) LoggingT
x -> Run (ExampleT context) -> m a
f RunDefault2 (ExampleT context) (ReaderT context) LoggingT
x
  restoreT :: forall (m :: * -> *) a.
Monad m =>
m (StT (ExampleT context) a) -> ExampleT context m a
restoreT = forall (m :: * -> *) (n' :: (* -> *) -> * -> *)
       (n :: (* -> *) -> * -> *) a (t :: (* -> *) -> * -> *).
(Monad m, Monad (n' m), MonadTransControl n,
 MonadTransControl n') =>
(n (n' m) a -> t m a) -> m (StT n' (StT n a)) -> t m a
defaultRestoreT2 forall context (m :: * -> *) a.
ReaderT context (LoggingT m) a -> ExampleT context m a
ExampleT

instance (MonadBaseControl b m) => MonadBaseControl b (ExampleT context m) where
  type StM (ExampleT context m) a = ComposeSt (ExampleT context) m a
  liftBaseWith :: forall a.
(RunInBase (ExampleT context m) b -> b a) -> ExampleT context m a
liftBaseWith = forall (t :: (* -> *) -> * -> *) (b :: * -> *) (m :: * -> *) a.
(MonadTransControl t, MonadBaseControl b m) =>
(RunInBaseDefault t m b -> b a) -> t m a
defaultLiftBaseWith
  restoreM :: forall a. StM (ExampleT context m) a -> ExampleT context m a
restoreM = forall (t :: (* -> *) -> * -> *) (b :: * -> *) (m :: * -> *) a.
(MonadTransControl t, MonadBaseControl b m) =>
ComposeSt t m a -> t m a
defaultRestoreM

instance (Monad m, MonadThrow m) => MonadFail (ExampleT context m) where
  fail :: (HasCallStack) => String -> ExampleT context m a
  fail :: forall a. HasCallStack => String -> ExampleT context m a
fail = forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe CallStack -> String -> FailureReason
Reason (forall a. a -> Maybe a
Just HasCallStack => CallStack
callStack)

-- * Results

data Result = Success
            | Failure FailureReason
            | DryRun
            | Cancelled
  deriving (Int -> Result -> ShowS
[Result] -> ShowS
Result -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Result] -> ShowS
$cshowList :: [Result] -> ShowS
show :: Result -> String
$cshow :: Result -> String
showsPrec :: Int -> Result -> ShowS
$cshowsPrec :: Int -> Result -> ShowS
Show, Result -> Result -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Result -> Result -> Bool
$c/= :: Result -> Result -> Bool
== :: Result -> Result -> Bool
$c== :: Result -> Result -> Bool
Eq)

data ShowEqBox = forall s. (Show s, Eq s) => SEB s
instance Show ShowEqBox where show :: ShowEqBox -> String
show (SEB s
x) = forall a. Show a => a -> String
show s
x
instance Eq ShowEqBox where (SEB s
x1) == :: ShowEqBox -> ShowEqBox -> Bool
== (SEB s
x2) = forall a. Show a => a -> String
show s
x1 forall a. Eq a => a -> a -> Bool
== forall a. Show a => a -> String
show s
x2

data FailureReason = Reason { FailureReason -> Maybe CallStack
failureCallStack :: Maybe CallStack
                            , FailureReason -> String
failureReason :: String }
                   | ExpectedButGot { failureCallStack :: Maybe CallStack
                                    , FailureReason -> ShowEqBox
failureValue1 :: ShowEqBox
                                    , FailureReason -> ShowEqBox
failureValue2 :: ShowEqBox }
                   | DidNotExpectButGot { failureCallStack :: Maybe CallStack
                                        , failureValue1 :: ShowEqBox }
                   | GotException { failureCallStack :: Maybe CallStack
                                  , FailureReason -> Maybe String
failureMessage :: Maybe String
                                  , FailureReason -> SomeExceptionWithEq
failureException :: SomeExceptionWithEq }
                   | Pending { failureCallStack :: Maybe CallStack
                             , FailureReason -> Maybe String
failurePendingMessage :: Maybe String }
                   | GetContextException { failureCallStack :: Maybe CallStack
                                         , failureException :: SomeExceptionWithEq }
                   | GotAsyncException { failureCallStack :: Maybe CallStack
                                       , failureMessage :: Maybe String
                                       , FailureReason -> SomeAsyncExceptionWithEq
failureAsyncException :: SomeAsyncExceptionWithEq }
                   | ChildrenFailed { failureCallStack :: Maybe CallStack
                                    , FailureReason -> Int
failureNumChildren :: Int }
#ifndef mingw32_HOST_OS
                   | RawImage { failureCallStack :: Maybe CallStack
                              , FailureReason -> String
failureFallback :: String
                              , FailureReason -> Image
failureRawImage :: Image }
#endif

  deriving (Int -> FailureReason -> ShowS
[FailureReason] -> ShowS
FailureReason -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FailureReason] -> ShowS
$cshowList :: [FailureReason] -> ShowS
show :: FailureReason -> String
$cshow :: FailureReason -> String
showsPrec :: Int -> FailureReason -> ShowS
$cshowsPrec :: Int -> FailureReason -> ShowS
Show, Typeable, FailureReason -> FailureReason -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FailureReason -> FailureReason -> Bool
$c/= :: FailureReason -> FailureReason -> Bool
== :: FailureReason -> FailureReason -> Bool
$c== :: FailureReason -> FailureReason -> Bool
Eq)

instance Exception FailureReason

instance Eq CallStack where
  CallStack
c1 == :: CallStack -> CallStack -> Bool
== CallStack
c2 = forall a. Show a => a -> String
show CallStack
c1 forall a. Eq a => a -> a -> Bool
== forall a. Show a => a -> String
show CallStack
c2

newtype SomeExceptionWithEq = SomeExceptionWithEq SomeException
instance Show SomeExceptionWithEq where
  show :: SomeExceptionWithEq -> String
show (SomeExceptionWithEq SomeException
e) = forall a. Show a => a -> String
show SomeException
e
instance Eq SomeExceptionWithEq where
  (SomeExceptionWithEq SomeException
e1) == :: SomeExceptionWithEq -> SomeExceptionWithEq -> Bool
== (SomeExceptionWithEq SomeException
e2) = forall a. Show a => a -> String
show SomeException
e1 forall a. Eq a => a -> a -> Bool
== forall a. Show a => a -> String
show SomeException
e2

newtype SomeAsyncExceptionWithEq = SomeAsyncExceptionWithEq SomeAsyncException
  deriving Int -> SomeAsyncExceptionWithEq -> ShowS
[SomeAsyncExceptionWithEq] -> ShowS
SomeAsyncExceptionWithEq -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SomeAsyncExceptionWithEq] -> ShowS
$cshowList :: [SomeAsyncExceptionWithEq] -> ShowS
show :: SomeAsyncExceptionWithEq -> String
$cshow :: SomeAsyncExceptionWithEq -> String
showsPrec :: Int -> SomeAsyncExceptionWithEq -> ShowS
$cshowsPrec :: Int -> SomeAsyncExceptionWithEq -> ShowS
Show
instance Eq SomeAsyncExceptionWithEq where
  (SomeAsyncExceptionWithEq SomeAsyncException
e1) == :: SomeAsyncExceptionWithEq -> SomeAsyncExceptionWithEq -> Bool
== (SomeAsyncExceptionWithEq SomeAsyncException
e2) = forall a. Show a => a -> String
show SomeAsyncException
e1 forall a. Eq a => a -> a -> Bool
== forall a. Show a => a -> String
show SomeAsyncException
e2

-- * Label stuff

data Label (l :: Symbol) a = Label

data LabelValue (l :: Symbol) a = LabelValue a

-- TODO: get rid of overlapping instance
-- Maybe look at https://kseo.github.io/posts/2017-02-05-avoid-overlapping-instances-with-closed-type-families.html
class HasLabel context (l :: Symbol) a where
  getLabelValue :: Label l a -> context -> a
instance HasLabel (LabelValue l a) l a where
  getLabelValue :: Label l a -> LabelValue l a -> a
getLabelValue Label l a
_ (LabelValue a
x) = a
x
instance {-# OVERLAPPING #-} HasLabel (LabelValue l a :> context) l a where
  getLabelValue :: Label l a -> (LabelValue l a :> context) -> a
getLabelValue Label l a
_ (LabelValue a
x :> context
_) = a
x
instance {-# OVERLAPPING #-} HasLabel context l a => HasLabel (intro :> context) l a where
  getLabelValue :: Label l a -> (intro :> context) -> a
getLabelValue Label l a
l (intro
_ :> context
ctx) = forall context (l :: Symbol) a.
HasLabel context l a =>
Label l a -> context -> a
getLabelValue Label l a
l context
ctx


-- * Free monad language

data (a :: *) :> (b :: *) = a :> b
  deriving Int -> (a :> b) -> ShowS
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall a b. (Show a, Show b) => Int -> (a :> b) -> ShowS
forall a b. (Show a, Show b) => [a :> b] -> ShowS
forall a b. (Show a, Show b) => (a :> b) -> String
showList :: [a :> b] -> ShowS
$cshowList :: forall a b. (Show a, Show b) => [a :> b] -> ShowS
show :: (a :> b) -> String
$cshow :: forall a b. (Show a, Show b) => (a :> b) -> String
showsPrec :: Int -> (a :> b) -> ShowS
$cshowsPrec :: forall a b. (Show a, Show b) => Int -> (a :> b) -> ShowS
Show
infixr :>

type ActionWith a = a -> IO ()

data NodeModuleInfo = NodeModuleInfo {
  NodeModuleInfo -> String
nodeModuleInfoModuleName :: String
  , NodeModuleInfo -> Maybe (IO ())
nodeModuleInfoFn :: Maybe (IO ())
  }

instance Show NodeModuleInfo where
  show :: NodeModuleInfo -> String
show (NodeModuleInfo {String
Maybe (IO ())
nodeModuleInfoFn :: Maybe (IO ())
nodeModuleInfoModuleName :: String
nodeModuleInfoFn :: NodeModuleInfo -> Maybe (IO ())
nodeModuleInfoModuleName :: NodeModuleInfo -> String
..}) = [i|#{nodeModuleInfoModuleName}<Has main? #{isJust nodeModuleInfoFn}>|]

-- | Options for an individual test node.
data NodeOptions = NodeOptions {
  NodeOptions -> Int
nodeOptionsVisibilityThreshold :: Int
  -- ^ The visibility threshold of the node. See the main docs for an explanation of this.
  , NodeOptions -> Bool
nodeOptionsCreateFolder :: Bool
  -- ^ Whether to create a folder in the on-disk test results for this node.
  -- Defaults to 'True', but can be turned off to reduce extraneous folders from nodes like 'Parallel'.
  , NodeOptions -> Bool
nodeOptionsRecordTime :: Bool
  -- ^ Whether to time this node.
  , NodeOptions -> Maybe NodeModuleInfo
nodeOptionsModuleInfo :: Maybe NodeModuleInfo
  -- ^ A main function run this entire node in isolation.
  } deriving Int -> NodeOptions -> ShowS
[NodeOptions] -> ShowS
NodeOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NodeOptions] -> ShowS
$cshowList :: [NodeOptions] -> ShowS
show :: NodeOptions -> String
$cshow :: NodeOptions -> String
showsPrec :: Int -> NodeOptions -> ShowS
$cshowsPrec :: Int -> NodeOptions -> ShowS
Show

-- | Reasonable default node options.
defaultNodeOptions :: NodeOptions
defaultNodeOptions :: NodeOptions
defaultNodeOptions = Int -> Bool -> Bool -> Maybe NodeModuleInfo -> NodeOptions
NodeOptions Int
100 Bool
True Bool
True forall a. Maybe a
Nothing

data SpecCommand context m next where
  Before'' :: {
    forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
location :: Maybe SrcLoc
    , forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
nodeOptions :: NodeOptions
    , forall context (m :: * -> *) next.
SpecCommand context m next -> String
label :: String
    , forall context (m :: * -> *) next.
SpecCommand context m next -> ExampleT context m ()
action :: ExampleT context m ()
    , forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
subspec :: SpecFree context m ()
    , forall context (m :: * -> *) next.
SpecCommand context m next -> next
next :: next
    } -> SpecCommand context m next

  After'' :: {
    location :: Maybe SrcLoc
    , nodeOptions :: NodeOptions
    , label :: String
    , action :: ExampleT context m ()
    , subspec :: SpecFree context m ()
    , next :: next
    } -> SpecCommand context m next

  Introduce'' :: (Typeable intro) => {
    location :: Maybe SrcLoc
    , nodeOptions :: NodeOptions
    , label :: String
    , ()
contextLabel :: Label l intro
    , ()
allocate :: ExampleT context m intro
    , ()
cleanup :: intro -> ExampleT context m ()
    , ()
subspecAugmented :: SpecFree (LabelValue l intro :> context) m ()
    , next :: next
    } -> SpecCommand context m next

  IntroduceWith'' :: {
    location :: Maybe SrcLoc
    , nodeOptions :: NodeOptions
    , label :: String
    , contextLabel :: Label l intro
    , ()
introduceAction :: (intro -> ExampleT context m [Result]) -> ExampleT context m ()
    , subspecAugmented :: SpecFree (LabelValue l intro :> context) m ()
    , next :: next
    } -> SpecCommand context m next

  Around'' :: {
    location :: Maybe SrcLoc
    , nodeOptions :: NodeOptions
    , label :: String
    , forall context (m :: * -> *) next.
SpecCommand context m next
-> ExampleT context m [Result] -> ExampleT context m ()
actionWith :: ExampleT context m [Result] -> ExampleT context m ()
    , subspec :: SpecFree context m ()
    , next :: next
    } -> SpecCommand context m next

  Describe'' :: {
    location :: Maybe SrcLoc
    , nodeOptions :: NodeOptions
    , label :: String
    , subspec :: SpecFree context m ()
    , next :: next
    } -> SpecCommand context m next

  Parallel'' :: {
    location :: Maybe SrcLoc
    , nodeOptions :: NodeOptions
    , subspec :: SpecFree context m ()
    , next :: next
    } -> SpecCommand context m next

  It'' :: { location :: Maybe SrcLoc
          , nodeOptions :: NodeOptions
          , label :: String
          , forall context (m :: * -> *) next.
SpecCommand context m next -> ExampleT context m ()
example :: ExampleT context m ()
          , next :: next } -> SpecCommand context m next

deriving instance Functor (SpecCommand context m)
deriving instance Foldable (SpecCommand context m)
deriving instance Traversable (SpecCommand context m)


type Spec context m = SpecFree context m ()
type SpecFree context m a = Free (SpecCommand context m) a

makeFree_ ''SpecCommand

instance Show t => Show (SpecCommand context m t) where
  showsPrec :: Int -> SpecCommand context m t -> ShowS
showsPrec = forall (f :: * -> *) a.
Show1 f =>
(Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS
liftShowsPrec forall a. Show a => Int -> a -> ShowS
showsPrec forall a. Show a => [a] -> ShowS
showList

instance Show1 (SpecCommand context m) where
  liftShowsPrec :: forall a.
(Int -> a -> ShowS)
-> ([a] -> ShowS) -> Int -> SpecCommand context m a -> ShowS
liftShowsPrec Int -> a -> ShowS
sp [a] -> ShowS
_ Int
d (Before'' {a
String
Maybe SrcLoc
SpecFree context m ()
NodeOptions
ExampleT context m ()
next :: a
subspec :: SpecFree context m ()
action :: ExampleT context m ()
label :: String
nodeOptions :: NodeOptions
location :: Maybe SrcLoc
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
action :: forall context (m :: * -> *) next.
SpecCommand context m next -> ExampleT context m ()
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
..}) = forall a. (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
showsUnaryWith Int -> a -> ShowS
sp [i|Before[#{label}]<#{show subspec}>|] Int
d a
next
  liftShowsPrec Int -> a -> ShowS
sp [a] -> ShowS
_ Int
d (After'' {a
String
Maybe SrcLoc
SpecFree context m ()
NodeOptions
ExampleT context m ()
next :: a
subspec :: SpecFree context m ()
action :: ExampleT context m ()
label :: String
nodeOptions :: NodeOptions
location :: Maybe SrcLoc
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
action :: forall context (m :: * -> *) next.
SpecCommand context m next -> ExampleT context m ()
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
..}) = forall a. (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
showsUnaryWith Int -> a -> ShowS
sp [i|After[#{label}]<#{show subspec}>|] Int
d a
next
  liftShowsPrec Int -> a -> ShowS
sp [a] -> ShowS
_ Int
d (Introduce'' {a
String
Maybe SrcLoc
SpecFree (LabelValue l intro :> context) m ()
NodeOptions
Label l intro
ExampleT context m intro
intro -> ExampleT context m ()
next :: a
subspecAugmented :: SpecFree (LabelValue l intro :> context) m ()
cleanup :: intro -> ExampleT context m ()
allocate :: ExampleT context m intro
contextLabel :: Label l intro
label :: String
nodeOptions :: NodeOptions
location :: Maybe SrcLoc
subspecAugmented :: ()
cleanup :: ()
allocate :: ()
contextLabel :: ()
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
..}) = forall a. (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
showsUnaryWith Int -> a -> ShowS
sp [i|Introduce[#{label}]<#{show subspecAugmented}>|] Int
d a
next
  liftShowsPrec Int -> a -> ShowS
sp [a] -> ShowS
_ Int
d (IntroduceWith'' {a
String
Maybe SrcLoc
SpecFree (LabelValue l intro :> context) m ()
NodeOptions
Label l intro
(intro -> ExampleT context m [Result]) -> ExampleT context m ()
next :: a
subspecAugmented :: SpecFree (LabelValue l intro :> context) m ()
introduceAction :: (intro -> ExampleT context m [Result]) -> ExampleT context m ()
contextLabel :: Label l intro
label :: String
nodeOptions :: NodeOptions
location :: Maybe SrcLoc
introduceAction :: ()
subspecAugmented :: ()
contextLabel :: ()
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
..}) = forall a. (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
showsUnaryWith Int -> a -> ShowS
sp [i|IntroduceWith[#{label}]<#{show subspecAugmented}>|] Int
d a
next
  liftShowsPrec Int -> a -> ShowS
sp [a] -> ShowS
_ Int
d (Around'' {a
String
Maybe SrcLoc
SpecFree context m ()
NodeOptions
ExampleT context m [Result] -> ExampleT context m ()
next :: a
subspec :: SpecFree context m ()
actionWith :: ExampleT context m [Result] -> ExampleT context m ()
label :: String
nodeOptions :: NodeOptions
location :: Maybe SrcLoc
actionWith :: forall context (m :: * -> *) next.
SpecCommand context m next
-> ExampleT context m [Result] -> ExampleT context m ()
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
..}) = forall a. (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
showsUnaryWith Int -> a -> ShowS
sp [i|Around[#{label}]<#{show subspec}>|] Int
d a
next
  liftShowsPrec Int -> a -> ShowS
sp [a] -> ShowS
_ Int
d (Describe'' {a
String
Maybe SrcLoc
SpecFree context m ()
NodeOptions
next :: a
subspec :: SpecFree context m ()
label :: String
nodeOptions :: NodeOptions
location :: Maybe SrcLoc
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
..}) = forall a. (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
showsUnaryWith Int -> a -> ShowS
sp [i|Describe[#{label}]<#{show subspec}>|] Int
d a
next
  liftShowsPrec Int -> a -> ShowS
sp [a] -> ShowS
_ Int
d (Parallel'' {a
Maybe SrcLoc
SpecFree context m ()
NodeOptions
next :: a
subspec :: SpecFree context m ()
nodeOptions :: NodeOptions
location :: Maybe SrcLoc
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
..}) = forall a. (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
showsUnaryWith Int -> a -> ShowS
sp [i|Parallel<#{show subspec}>|] Int
d a
next
  liftShowsPrec Int -> a -> ShowS
sp [a] -> ShowS
_ Int
d (It'' {a
String
Maybe SrcLoc
NodeOptions
ExampleT context m ()
next :: a
example :: ExampleT context m ()
label :: String
nodeOptions :: NodeOptions
location :: Maybe SrcLoc
example :: forall context (m :: * -> *) next.
SpecCommand context m next -> ExampleT context m ()
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
..}) = forall a. (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
showsUnaryWith Int -> a -> ShowS
sp [i|It[#{label}]|] Int
d a
next

-- * ----------------------------------------------------------

-- | Perform an action before a given spec tree.
before :: (HasCallStack) =>
  String
  -- ^ Label for this context manager
  -> ExampleT context m ()
  -- ^ Action to perform
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
before :: forall context (m :: * -> *).
HasCallStack =>
String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
before = forall context (m :: * -> *).
HasCallStack =>
NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
before' (NodeOptions
defaultNodeOptions { nodeOptionsVisibilityThreshold :: Int
nodeOptionsVisibilityThreshold = Int
100 })

-- | Perform an action before a given spec tree.
before' :: (HasCallStack) =>
  NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ String label for this context manager
  -> ExampleT context m ()
  -- ^ Action to perform
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
before' :: forall context (m :: * -> *).
HasCallStack =>
NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
before' = forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
before'' (forall a b. (a, b) -> b
snd forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. [a] -> Maybe a
headMay (forall a. Int -> [a] -> [a]
drop Int
1 forall a b. (a -> b) -> a -> b
$ CallStack -> [(String, SrcLoc)]
getCallStack HasCallStack => CallStack
callStack))

-- | Perform an action before a given spec tree.
before'' :: (HasCallStack) =>
  Maybe SrcLoc
  -- ^ Location of this call
  -> NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ String label for this context manager
  -> ExampleT context m ()
  -- ^ Action to perform
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()

-- * ----------------------------------------------------------

-- | Perform an action after a given spec tree.
after :: (HasCallStack) =>
  String
  -- ^ Label for this context manager
  -> ExampleT context m ()
  -- ^ Action to perform
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
after :: forall context (m :: * -> *).
HasCallStack =>
String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
after = forall context (m :: * -> *).
HasCallStack =>
NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
after' (NodeOptions
defaultNodeOptions { nodeOptionsVisibilityThreshold :: Int
nodeOptionsVisibilityThreshold = Int
100 })

-- | Perform an action after a given spec tree.
after' :: (HasCallStack) =>
  NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ String label for this context manager
  -> ExampleT context m ()
  -- ^ Action to perform
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
after' :: forall context (m :: * -> *).
HasCallStack =>
NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
after' = forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
after'' (forall a b. (a, b) -> b
snd forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. [a] -> Maybe a
headMay (forall a. Int -> [a] -> [a]
drop Int
1 forall a b. (a -> b) -> a -> b
$ CallStack -> [(String, SrcLoc)]
getCallStack HasCallStack => CallStack
callStack))

-- | Perform an action after a given spec tree.
after'' :: (HasCallStack) =>
  Maybe SrcLoc
  -- ^ Location of this call
  -> NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ String label for this context manager
  -> ExampleT context m ()
  -- ^ Action to perform
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()

-- * ----------------------------------------------------------

-- | Introduce a new value and make it available to the child spec tree.
introduce :: (HasCallStack, Typeable intro) =>
  String
  -- ^ String label for this node
  -> Label l intro
  -- ^ 'Label' under which to introduce the value
  -> ExampleT context m intro
  -- ^ Action to produce the new value (of type 'intro')
  -> (intro -> ExampleT context m ())
  -- ^ Action to clean up the new value
  -> SpecFree (LabelValue l intro :> context) m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
introduce :: forall intro (l :: Symbol) context (m :: * -> *).
(HasCallStack, Typeable intro) =>
String
-> Label l intro
-> ExampleT context m intro
-> (intro -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> SpecFree context m ()
introduce = forall intro (l :: Symbol) context (m :: * -> *).
(HasCallStack, Typeable intro) =>
NodeOptions
-> String
-> Label l intro
-> ExampleT context m intro
-> (intro -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> SpecFree context m ()
introduce' (NodeOptions
defaultNodeOptions { nodeOptionsVisibilityThreshold :: Int
nodeOptionsVisibilityThreshold = Int
100 })

-- | Introduce a new value and make it available to the child spec tree.
introduce' :: (HasCallStack, Typeable intro) =>
  NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ String label for this node
  -> Label l intro
  -- ^ 'Label' under which to introduce the value
  -> ExampleT context m intro
  -- ^ Action to produce the new value (of type 'intro')
  -> (intro -> ExampleT context m ())
  -- ^ Action to clean up the new value
  -> SpecFree (LabelValue l intro :> context) m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
introduce' :: forall intro (l :: Symbol) context (m :: * -> *).
(HasCallStack, Typeable intro) =>
NodeOptions
-> String
-> Label l intro
-> ExampleT context m intro
-> (intro -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> SpecFree context m ()
introduce' = forall intro (l :: Symbol) context (m :: * -> *).
(HasCallStack, Typeable intro) =>
Maybe SrcLoc
-> NodeOptions
-> String
-> Label l intro
-> ExampleT context m intro
-> (intro -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> SpecFree context m ()
introduce'' (forall a b. (a, b) -> b
snd forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. [a] -> Maybe a
headMay (forall a. Int -> [a] -> [a]
drop Int
1 forall a b. (a -> b) -> a -> b
$ CallStack -> [(String, SrcLoc)]
getCallStack HasCallStack => CallStack
callStack))

-- | Introduce a new value and make it available to the child spec tree.
introduce'' :: (HasCallStack, Typeable intro) =>
  Maybe SrcLoc
  -- ^ Location of this call
  -> NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ String label for this node
  -> Label l intro
  -- ^ 'Label' under which to introduce the value
  -> ExampleT context m intro
  -- ^ Action to produce the new value (of type 'intro')
  -> (intro -> ExampleT context m ())
  -- ^ Action to clean up the new value
  -> SpecFree (LabelValue l intro :> context) m ()
  -- ^ Child spec tree
  -> SpecFree context m ()

-- * ----------------------------------------------------------

-- | Introduce a new value in an 'around' fashion, so it can be used with context managers like withFile or bracket.
introduceWith :: (HasCallStack) =>
  String
  -- ^ String label for this node
  -> Label l intro
  -- ^ 'Label' under which to introduce the value
  -> ((intro -> ExampleT context m [Result]) -> ExampleT context m ())
  -- ^ Callback to receive the new value and the child tree.
  -> SpecFree (LabelValue l intro :> context) m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
introduceWith :: forall (l :: Symbol) intro context (m :: * -> *).
HasCallStack =>
String
-> Label l intro
-> ((intro -> ExampleT context m [Result])
    -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> SpecFree context m ()
introduceWith = forall (l :: Symbol) intro context (m :: * -> *).
HasCallStack =>
NodeOptions
-> String
-> Label l intro
-> ((intro -> ExampleT context m [Result])
    -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> SpecFree context m ()
introduceWith' (NodeOptions
defaultNodeOptions { nodeOptionsVisibilityThreshold :: Int
nodeOptionsVisibilityThreshold = Int
100 })

-- | Introduce a new value in an 'around' fashion, so it can be used with context managers like withFile or bracket.
introduceWith' :: (HasCallStack) =>
  NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ String label for this node
  -> Label l intro
  -- ^ 'Label' under which to introduce the value
  -> ((intro -> ExampleT context m [Result]) -> ExampleT context m ())
  -- ^ Callback to receive the new value and the child tree.
  -> SpecFree (LabelValue l intro :> context) m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
introduceWith' :: forall (l :: Symbol) intro context (m :: * -> *).
HasCallStack =>
NodeOptions
-> String
-> Label l intro
-> ((intro -> ExampleT context m [Result])
    -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> SpecFree context m ()
introduceWith' = forall (l :: Symbol) intro context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> Label l intro
-> ((intro -> ExampleT context m [Result])
    -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> SpecFree context m ()
introduceWith'' (forall a b. (a, b) -> b
snd forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. [a] -> Maybe a
headMay (forall a. Int -> [a] -> [a]
drop Int
1 forall a b. (a -> b) -> a -> b
$ CallStack -> [(String, SrcLoc)]
getCallStack HasCallStack => CallStack
callStack))

-- | Introduce a new value in an 'around' fashion, so it can be used with context managers like withFile or bracket.
introduceWith'' :: (HasCallStack) =>
  Maybe SrcLoc
  -- ^ Location of this call
  -> NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ String label for this node
  -> Label l intro
  -- ^ 'Label' under which to introduce the value
  -> ((intro -> ExampleT context m [Result]) -> ExampleT context m ())
  -- ^ Callback to receive the new value and the child tree.
  -> SpecFree (LabelValue l intro :> context) m ()
  -- ^ Child spec tree
  -> SpecFree context m ()

-- * ----------------------------------------------------------

-- | Run an action around the given child subtree. Useful for context managers like withFile or bracket.
around :: (HasCallStack) =>
  String
  -> (ExampleT context m [Result] -> ExampleT context m ())
  -- ^ Callback to run the child tree
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
around :: forall context (m :: * -> *).
HasCallStack =>
String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
around = forall context (m :: * -> *).
HasCallStack =>
NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
around' (NodeOptions
defaultNodeOptions { nodeOptionsVisibilityThreshold :: Int
nodeOptionsVisibilityThreshold = Int
100 })

-- | Run an action around the given child subtree. Useful for context managers like withFile or bracket.
around' :: (HasCallStack) =>
  NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ String label for this node
  -> (ExampleT context m [Result] -> ExampleT context m ())
  -- ^ Callback to run the child tree
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
around' :: forall context (m :: * -> *).
HasCallStack =>
NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
around' = forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
around'' (forall a b. (a, b) -> b
snd forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. [a] -> Maybe a
headMay (forall a. Int -> [a] -> [a]
drop Int
1 forall a b. (a -> b) -> a -> b
$ CallStack -> [(String, SrcLoc)]
getCallStack HasCallStack => CallStack
callStack))

-- | Run an action around the given child subtree. Useful for context managers like withFile or bracket.
around'' :: (HasCallStack) =>
  Maybe SrcLoc
  -- ^ Location of this call
  -> NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ String label for this node
  -> (ExampleT context m [Result] -> ExampleT context m ())
  -- ^ Callback to run the child tree
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()


-- * ----------------------------------------------------------

-- | Define a group of tests.
describe :: (HasCallStack) =>
  String
  -- ^ Label for this group
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
describe :: forall context (m :: * -> *).
HasCallStack =>
String -> SpecFree context m () -> SpecFree context m ()
describe = forall context (m :: * -> *).
HasCallStack =>
NodeOptions
-> String -> SpecFree context m () -> SpecFree context m ()
describe' (NodeOptions
defaultNodeOptions { nodeOptionsVisibilityThreshold :: Int
nodeOptionsVisibilityThreshold = Int
50 })

-- | Define a group of tests.
describe' :: (HasCallStack) =>
  NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ Label for this group
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
describe' :: forall context (m :: * -> *).
HasCallStack =>
NodeOptions
-> String -> SpecFree context m () -> SpecFree context m ()
describe' = forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> SpecFree context m ()
-> SpecFree context m ()
describe'' (forall a b. (a, b) -> b
snd forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. [a] -> Maybe a
headMay (forall a. Int -> [a] -> [a]
drop Int
1 forall a b. (a -> b) -> a -> b
$ CallStack -> [(String, SrcLoc)]
getCallStack HasCallStack => CallStack
callStack))

-- | Define a group of tests.
describe'' :: (HasCallStack) =>
  Maybe SrcLoc
  -- ^ Location of this call
  -> NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ Label for this group
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()

-- * ----------------------------------------------------------

-- | Run a group of tests in parallel.
parallel :: (HasCallStack) =>
  SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
parallel :: forall context (m :: * -> *).
HasCallStack =>
SpecFree context m () -> SpecFree context m ()
parallel = forall context (m :: * -> *).
HasCallStack =>
NodeOptions -> SpecFree context m () -> SpecFree context m ()
parallel' (NodeOptions
defaultNodeOptions { nodeOptionsVisibilityThreshold :: Int
nodeOptionsVisibilityThreshold = Int
70 })

-- | Run a group of tests in parallel.
parallel' :: (HasCallStack) =>
  NodeOptions
  -- ^ Custom options for this node
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
parallel' :: forall context (m :: * -> *).
HasCallStack =>
NodeOptions -> SpecFree context m () -> SpecFree context m ()
parallel' = forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions -> SpecFree context m () -> SpecFree context m ()
parallel'' (forall a b. (a, b) -> b
snd forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. [a] -> Maybe a
headMay (forall a. Int -> [a] -> [a]
drop Int
1 forall a b. (a -> b) -> a -> b
$ CallStack -> [(String, SrcLoc)]
getCallStack HasCallStack => CallStack
callStack))

-- | Run a group of tests in parallel.
parallel'' :: (HasCallStack) =>
  Maybe SrcLoc
  -- ^ Location of this call
  -> NodeOptions
  -- ^ Custom options for this node
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()

-- * ----------------------------------------------------------

-- | Define a single test example.
it :: (HasCallStack) =>
  String
  -- ^ Label for the example.
  -> ExampleT context m ()
  -- ^ The test example
  -> Free (SpecCommand context m) ()
it :: forall context (m :: * -> *).
HasCallStack =>
String -> ExampleT context m () -> Free (SpecCommand context m) ()
it = forall context (m :: * -> *).
HasCallStack =>
NodeOptions
-> String
-> ExampleT context m ()
-> Free (SpecCommand context m) ()
it' (NodeOptions
defaultNodeOptions { nodeOptionsVisibilityThreshold :: Int
nodeOptionsVisibilityThreshold = Int
0 })

-- | Define a single test example.
it' :: (HasCallStack) =>
  NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ String label for the example.
  -> ExampleT context m ()
  -- ^ The test example
  -> Free (SpecCommand context m) ()
it' :: forall context (m :: * -> *).
HasCallStack =>
NodeOptions
-> String
-> ExampleT context m ()
-> Free (SpecCommand context m) ()
it' = forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> Free (SpecCommand context m) ()
it'' (forall a b. (a, b) -> b
snd forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. [a] -> Maybe a
headMay (forall a. Int -> [a] -> [a]
drop Int
1 forall a b. (a -> b) -> a -> b
$ CallStack -> [(String, SrcLoc)]
getCallStack HasCallStack => CallStack
callStack))

-- | Define a single test example.
it'' :: (HasCallStack) =>
  Maybe SrcLoc
  -- ^ Location of this call
  -> NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ String label for the example.
  -> ExampleT context m ()
  -- ^ The test example
  -> Free (SpecCommand context m) ()

-- * ----------------------------------------------------------

-- | Same as 'before', but applied individually to every 'it' node.
beforeEach :: (HasCallStack) =>
  String
  -- ^ String label for this context manager
  -> (ExampleT context m ())
  -- ^ Action to perform
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
beforeEach :: forall context (m :: * -> *).
HasCallStack =>
String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
beforeEach = forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
beforeEach' (forall a b. (a, b) -> b
snd forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. [a] -> Maybe a
headMay (CallStack -> [(String, SrcLoc)]
getCallStack HasCallStack => CallStack
callStack)) (NodeOptions
defaultNodeOptions { nodeOptionsVisibilityThreshold :: Int
nodeOptionsVisibilityThreshold = Int
100 })

-- | Perform an action before each example in a given spec tree.
beforeEach' :: (HasCallStack) =>
  Maybe SrcLoc
  -- ^ Location of this call
  -> NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ String label for this context manager
  -> (ExampleT context m ())
  -- ^ Action to perform
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
beforeEach' :: forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(Before'' {String
Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
ExampleT context m ()
next :: Free (SpecCommand context m) ()
subspec :: Free (SpecCommand context m) ()
action :: ExampleT context m ()
label :: String
nodeOptions :: NodeOptions
location :: Maybe SrcLoc
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
action :: forall context (m :: * -> *) next.
SpecCommand context m next -> ExampleT context m ()
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
..})) = forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { subspec :: Free (SpecCommand context m) ()
subspec = forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
subspec, next :: Free (SpecCommand context m) ()
next = forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
next })
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(After'' {String
Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
ExampleT context m ()
next :: Free (SpecCommand context m) ()
subspec :: Free (SpecCommand context m) ()
action :: ExampleT context m ()
label :: String
nodeOptions :: NodeOptions
location :: Maybe SrcLoc
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
action :: forall context (m :: * -> *) next.
SpecCommand context m next -> ExampleT context m ()
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
..})) = forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { subspec :: Free (SpecCommand context m) ()
subspec = forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
subspec, next :: Free (SpecCommand context m) ()
next = forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
next })
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(Around'' {String
Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
ExampleT context m [Result] -> ExampleT context m ()
next :: Free (SpecCommand context m) ()
subspec :: Free (SpecCommand context m) ()
actionWith :: ExampleT context m [Result] -> ExampleT context m ()
label :: String
nodeOptions :: NodeOptions
location :: Maybe SrcLoc
actionWith :: forall context (m :: * -> *) next.
SpecCommand context m next
-> ExampleT context m [Result] -> ExampleT context m ()
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
..})) = forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { subspec :: Free (SpecCommand context m) ()
subspec = forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
subspec, next :: Free (SpecCommand context m) ()
next = forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
next })
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(Describe'' {String
Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
next :: Free (SpecCommand context m) ()
subspec :: Free (SpecCommand context m) ()
label :: String
nodeOptions :: NodeOptions
location :: Maybe SrcLoc
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
..})) = forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { subspec :: Free (SpecCommand context m) ()
subspec = forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
subspec, next :: Free (SpecCommand context m) ()
next = forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
next })
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(Parallel'' {Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
next :: Free (SpecCommand context m) ()
subspec :: Free (SpecCommand context m) ()
nodeOptions :: NodeOptions
location :: Maybe SrcLoc
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
..})) = forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { subspec :: Free (SpecCommand context m) ()
subspec = forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
subspec, next :: Free (SpecCommand context m) ()
next = forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
next })
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(It'' {String
Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
ExampleT context m ()
next :: Free (SpecCommand context m) ()
example :: ExampleT context m ()
label :: String
nodeOptions :: NodeOptions
location :: Maybe SrcLoc
example :: forall context (m :: * -> *) next.
SpecCommand context m next -> ExampleT context m ()
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
..})) = forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (forall context (m :: * -> *) next.
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> next
-> SpecCommand context m next
Before'' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { next :: Free (SpecCommand context m) ()
next = forall (f :: * -> *) a. a -> Free f a
Pure () })) (forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
next))
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free (Introduce'' Maybe SrcLoc
loci NodeOptions
noi String
li Label l intro
cl ExampleT context m intro
alloc intro -> ExampleT context m ()
clean SpecFree (LabelValue l intro :> context) m ()
subspec Free (SpecCommand context m) ()
next)) = forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (forall l (intro :: Symbol) context (m :: * -> *) next.
Typeable l =>
Maybe SrcLoc
-> NodeOptions
-> String
-> Label intro l
-> ExampleT context m l
-> (l -> ExampleT context m ())
-> SpecFree (LabelValue intro l :> context) m ()
-> next
-> SpecCommand context m next
Introduce'' Maybe SrcLoc
loci NodeOptions
noi String
li Label l intro
cl ExampleT context m intro
alloc intro -> ExampleT context m ()
clean (forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT (LabelValue l intro :> context) m ()
f' SpecFree (LabelValue l intro :> context) m ()
subspec) (forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
next))
  where f' :: ExampleT (LabelValue l intro :> context) m ()
f' = forall context (m :: * -> *) a.
ReaderT context (LoggingT m) a -> ExampleT context m a
ExampleT forall a b. (a -> b) -> a -> b
$ forall r' r (m :: * -> *) a.
(r' -> r) -> ReaderT r m a -> ReaderT r' m a
withReaderT (\(LabelValue l intro
_ :> context
context) -> context
context) forall a b. (a -> b) -> a -> b
$ forall context (m :: * -> *) a.
ExampleT context m a -> ReaderT context (LoggingT m) a
unExampleT ExampleT context m ()
f
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free (IntroduceWith'' Maybe SrcLoc
loci NodeOptions
noi String
li Label l intro
cl (intro -> ExampleT context m [Result]) -> ExampleT context m ()
action SpecFree (LabelValue l intro :> context) m ()
subspec Free (SpecCommand context m) ()
next)) = forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (forall (l :: Symbol) intro context (m :: * -> *) next.
Maybe SrcLoc
-> NodeOptions
-> String
-> Label l intro
-> ((intro -> ExampleT context m [Result])
    -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> next
-> SpecCommand context m next
IntroduceWith'' Maybe SrcLoc
loci NodeOptions
noi String
li Label l intro
cl (intro -> ExampleT context m [Result]) -> ExampleT context m ()
action (forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT (LabelValue l intro :> context) m ()
f' SpecFree (LabelValue l intro :> context) m ()
subspec) (forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
next))
  where f' :: ExampleT (LabelValue l intro :> context) m ()
f' = forall context (m :: * -> *) a.
ReaderT context (LoggingT m) a -> ExampleT context m a
ExampleT forall a b. (a -> b) -> a -> b
$ forall r' r (m :: * -> *) a.
(r' -> r) -> ReaderT r m a -> ReaderT r' m a
withReaderT (\(LabelValue l intro
_ :> context
context) -> context
context) forall a b. (a -> b) -> a -> b
$ forall context (m :: * -> *) a.
ExampleT context m a -> ReaderT context (LoggingT m) a
unExampleT ExampleT context m ()
f
beforeEach' Maybe SrcLoc
_ NodeOptions
_ String
_ ExampleT context m ()
_ (Pure ()
x) = forall (f :: * -> *) a. a -> Free f a
Pure ()
x

-- * ----------------------------------------------------------

-- | Same as 'after', but applied individually to every 'it' node.
afterEach :: (HasCallStack) =>
  String
  -- ^ String label for this context manager
  -> (ExampleT context m ())
  -- ^ Action to perform
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
afterEach :: forall context (m :: * -> *).
HasCallStack =>
String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
afterEach = forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
afterEach' (forall a b. (a, b) -> b
snd forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. [a] -> Maybe a
headMay (CallStack -> [(String, SrcLoc)]
getCallStack HasCallStack => CallStack
callStack)) (NodeOptions
defaultNodeOptions { nodeOptionsVisibilityThreshold :: Int
nodeOptionsVisibilityThreshold = Int
100 })

-- | Perform an action after each example in a given spec tree.
afterEach' :: (HasCallStack) =>
  Maybe SrcLoc
  -- ^ Location of this call
  -> NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ Label for this context manager
  -> (ExampleT context m ())
  -- ^ Action to perform
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
afterEach' :: forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(Before'' {String
Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
ExampleT context m ()
next :: Free (SpecCommand context m) ()
subspec :: Free (SpecCommand context m) ()
action :: ExampleT context m ()
label :: String
nodeOptions :: NodeOptions
location :: Maybe SrcLoc
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
action :: forall context (m :: * -> *) next.
SpecCommand context m next -> ExampleT context m ()
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
..})) = forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { subspec :: Free (SpecCommand context m) ()
subspec = forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
subspec, next :: Free (SpecCommand context m) ()
next = forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
next })
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(After'' {String
Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
ExampleT context m ()
next :: Free (SpecCommand context m) ()
subspec :: Free (SpecCommand context m) ()
action :: ExampleT context m ()
label :: String
nodeOptions :: NodeOptions
location :: Maybe SrcLoc
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
action :: forall context (m :: * -> *) next.
SpecCommand context m next -> ExampleT context m ()
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
..})) = forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { subspec :: Free (SpecCommand context m) ()
subspec = forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
subspec, next :: Free (SpecCommand context m) ()
next = forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
next })
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(Around'' {String
Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
ExampleT context m [Result] -> ExampleT context m ()
next :: Free (SpecCommand context m) ()
subspec :: Free (SpecCommand context m) ()
actionWith :: ExampleT context m [Result] -> ExampleT context m ()
label :: String
nodeOptions :: NodeOptions
location :: Maybe SrcLoc
actionWith :: forall context (m :: * -> *) next.
SpecCommand context m next
-> ExampleT context m [Result] -> ExampleT context m ()
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
..})) = forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { subspec :: Free (SpecCommand context m) ()
subspec = forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
subspec, next :: Free (SpecCommand context m) ()
next = forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
next })
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(Describe'' {String
Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
next :: Free (SpecCommand context m) ()
subspec :: Free (SpecCommand context m) ()
label :: String
nodeOptions :: NodeOptions
location :: Maybe SrcLoc
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
..})) = forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { subspec :: Free (SpecCommand context m) ()
subspec = forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
subspec, next :: Free (SpecCommand context m) ()
next = forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
next })
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(Parallel'' {Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
next :: Free (SpecCommand context m) ()
subspec :: Free (SpecCommand context m) ()
nodeOptions :: NodeOptions
location :: Maybe SrcLoc
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
..})) = forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { subspec :: Free (SpecCommand context m) ()
subspec = forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
subspec, next :: Free (SpecCommand context m) ()
next = forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
next })
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(It'' {String
Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
ExampleT context m ()
next :: Free (SpecCommand context m) ()
example :: ExampleT context m ()
label :: String
nodeOptions :: NodeOptions
location :: Maybe SrcLoc
example :: forall context (m :: * -> *) next.
SpecCommand context m next -> ExampleT context m ()
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
..})) = forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (forall context (m :: * -> *) next.
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> next
-> SpecCommand context m next
After'' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { next :: Free (SpecCommand context m) ()
next = forall (f :: * -> *) a. a -> Free f a
Pure () })) (forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
next))
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free (Introduce'' Maybe SrcLoc
loci NodeOptions
noi String
li Label l intro
cl ExampleT context m intro
alloc intro -> ExampleT context m ()
clean SpecFree (LabelValue l intro :> context) m ()
subspec Free (SpecCommand context m) ()
next)) = forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (forall l (intro :: Symbol) context (m :: * -> *) next.
Typeable l =>
Maybe SrcLoc
-> NodeOptions
-> String
-> Label intro l
-> ExampleT context m l
-> (l -> ExampleT context m ())
-> SpecFree (LabelValue intro l :> context) m ()
-> next
-> SpecCommand context m next
Introduce'' Maybe SrcLoc
loci NodeOptions
noi String
li Label l intro
cl ExampleT context m intro
alloc intro -> ExampleT context m ()
clean (forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT (LabelValue l intro :> context) m ()
f' SpecFree (LabelValue l intro :> context) m ()
subspec) (forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
next))
  where f' :: ExampleT (LabelValue l intro :> context) m ()
f' = forall context (m :: * -> *) a.
ReaderT context (LoggingT m) a -> ExampleT context m a
ExampleT forall a b. (a -> b) -> a -> b
$ forall r' r (m :: * -> *) a.
(r' -> r) -> ReaderT r m a -> ReaderT r' m a
withReaderT (\(LabelValue l intro
_ :> context
context) -> context
context) forall a b. (a -> b) -> a -> b
$ forall context (m :: * -> *) a.
ExampleT context m a -> ReaderT context (LoggingT m) a
unExampleT ExampleT context m ()
f
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free (IntroduceWith'' Maybe SrcLoc
loci NodeOptions
noi String
li Label l intro
cl (intro -> ExampleT context m [Result]) -> ExampleT context m ()
action SpecFree (LabelValue l intro :> context) m ()
subspec Free (SpecCommand context m) ()
next)) = forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (forall (l :: Symbol) intro context (m :: * -> *) next.
Maybe SrcLoc
-> NodeOptions
-> String
-> Label l intro
-> ((intro -> ExampleT context m [Result])
    -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> next
-> SpecCommand context m next
IntroduceWith'' Maybe SrcLoc
loci NodeOptions
noi String
li Label l intro
cl (intro -> ExampleT context m [Result]) -> ExampleT context m ()
action (forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT (LabelValue l intro :> context) m ()
f' SpecFree (LabelValue l intro :> context) m ()
subspec) (forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
next))
  where f' :: ExampleT (LabelValue l intro :> context) m ()
f' = forall context (m :: * -> *) a.
ReaderT context (LoggingT m) a -> ExampleT context m a
ExampleT forall a b. (a -> b) -> a -> b
$ forall r' r (m :: * -> *) a.
(r' -> r) -> ReaderT r m a -> ReaderT r' m a
withReaderT (\(LabelValue l intro
_ :> context
context) -> context
context) forall a b. (a -> b) -> a -> b
$ forall context (m :: * -> *) a.
ExampleT context m a -> ReaderT context (LoggingT m) a
unExampleT ExampleT context m ()
f
afterEach' Maybe SrcLoc
_ NodeOptions
_ String
_ ExampleT context m ()
_ (Pure ()
x) = forall (f :: * -> *) a. a -> Free f a
Pure ()
x

-- * ----------------------------------------------------------

-- | Same as 'around', but applied individually to every 'it' node.
aroundEach :: (Monad m, HasCallStack) =>
  String
  -- ^ String label for this context manager
  -> (ExampleT context m [Result] -> ExampleT context m ())
  -- ^ Callback to run the child tree
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
aroundEach :: forall (m :: * -> *) context.
(Monad m, HasCallStack) =>
String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
aroundEach = forall (m :: * -> *) context.
(Monad m, HasCallStack) =>
Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
aroundEach' (forall a b. (a, b) -> b
snd forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. [a] -> Maybe a
headMay (CallStack -> [(String, SrcLoc)]
getCallStack HasCallStack => CallStack
callStack)) (NodeOptions
defaultNodeOptions { nodeOptionsVisibilityThreshold :: Int
nodeOptionsVisibilityThreshold = Int
100 })

aroundEach' :: (Monad m, HasCallStack) =>
  Maybe SrcLoc
  -- ^ Location of this call
  -> NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ String label for this context manager
  -> (ExampleT context m [Result] -> ExampleT context m ())
  -- ^ Callback to run the child tree
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
aroundEach' :: forall (m :: * -> *) context.
(Monad m, HasCallStack) =>
Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(Before'' {String
Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
ExampleT context m ()
next :: Free (SpecCommand context m) ()
subspec :: Free (SpecCommand context m) ()
action :: ExampleT context m ()
label :: String
nodeOptions :: NodeOptions
location :: Maybe SrcLoc
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
action :: forall context (m :: * -> *) next.
SpecCommand context m next -> ExampleT context m ()
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
..})) = forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { subspec :: Free (SpecCommand context m) ()
subspec = forall (m :: * -> *) context.
(Monad m, HasCallStack) =>
Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f Free (SpecCommand context m) ()
subspec, next :: Free (SpecCommand context m) ()
next = forall (m :: * -> *) context.
(Monad m, HasCallStack) =>
Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f Free (SpecCommand context m) ()
next })
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(After'' {String
Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
ExampleT context m ()
next :: Free (SpecCommand context m) ()
subspec :: Free (SpecCommand context m) ()
action :: ExampleT context m ()
label :: String
nodeOptions :: NodeOptions
location :: Maybe SrcLoc
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
action :: forall context (m :: * -> *) next.
SpecCommand context m next -> ExampleT context m ()
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
..})) = forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { subspec :: Free (SpecCommand context m) ()
subspec = forall (m :: * -> *) context.
(Monad m, HasCallStack) =>
Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f Free (SpecCommand context m) ()
subspec, next :: Free (SpecCommand context m) ()
next = forall (m :: * -> *) context.
(Monad m, HasCallStack) =>
Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f Free (SpecCommand context m) ()
next })
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(Around'' {String
Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
ExampleT context m [Result] -> ExampleT context m ()
next :: Free (SpecCommand context m) ()
subspec :: Free (SpecCommand context m) ()
actionWith :: ExampleT context m [Result] -> ExampleT context m ()
label :: String
nodeOptions :: NodeOptions
location :: Maybe SrcLoc
actionWith :: forall context (m :: * -> *) next.
SpecCommand context m next
-> ExampleT context m [Result] -> ExampleT context m ()
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
..})) = forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { subspec :: Free (SpecCommand context m) ()
subspec = forall (m :: * -> *) context.
(Monad m, HasCallStack) =>
Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f Free (SpecCommand context m) ()
subspec, next :: Free (SpecCommand context m) ()
next = forall (m :: * -> *) context.
(Monad m, HasCallStack) =>
Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f Free (SpecCommand context m) ()
next })
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(Describe'' {String
Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
next :: Free (SpecCommand context m) ()
subspec :: Free (SpecCommand context m) ()
label :: String
nodeOptions :: NodeOptions
location :: Maybe SrcLoc
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
..})) = forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { subspec :: Free (SpecCommand context m) ()
subspec = forall (m :: * -> *) context.
(Monad m, HasCallStack) =>
Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f Free (SpecCommand context m) ()
subspec, next :: Free (SpecCommand context m) ()
next = forall (m :: * -> *) context.
(Monad m, HasCallStack) =>
Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f Free (SpecCommand context m) ()
next })
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(Parallel'' {Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
next :: Free (SpecCommand context m) ()
subspec :: Free (SpecCommand context m) ()
nodeOptions :: NodeOptions
location :: Maybe SrcLoc
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
..})) = forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { subspec :: Free (SpecCommand context m) ()
subspec = forall (m :: * -> *) context.
(Monad m, HasCallStack) =>
Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f Free (SpecCommand context m) ()
subspec, next :: Free (SpecCommand context m) ()
next = forall (m :: * -> *) context.
(Monad m, HasCallStack) =>
Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f Free (SpecCommand context m) ()
next })
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(It'' {String
Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
ExampleT context m ()
next :: Free (SpecCommand context m) ()
example :: ExampleT context m ()
label :: String
nodeOptions :: NodeOptions
location :: Maybe SrcLoc
example :: forall context (m :: * -> *) next.
SpecCommand context m next -> ExampleT context m ()
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
..})) = forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (forall context (m :: * -> *) next.
Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> next
-> SpecCommand context m next
Around'' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f (forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { next :: Free (SpecCommand context m) ()
next = forall (f :: * -> *) a. a -> Free f a
Pure () })) (forall (m :: * -> *) context.
(Monad m, HasCallStack) =>
Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f Free (SpecCommand context m) ()
next))
aroundEach' Maybe SrcLoc
_no NodeOptions
_ String
_ ExampleT context m [Result] -> ExampleT context m ()
_ (Pure ()
x) = forall (f :: * -> *) a. a -> Free f a
Pure ()
x
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f (Free (IntroduceWith'' Maybe SrcLoc
loci NodeOptions
noi String
li Label l intro
cl (intro -> ExampleT context m [Result]) -> ExampleT context m ()
action SpecFree (LabelValue l intro :> context) m ()
subspec Free (SpecCommand context m) ()
next)) = forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (forall (l :: Symbol) intro context (m :: * -> *) next.
Maybe SrcLoc
-> NodeOptions
-> String
-> Label l intro
-> ((intro -> ExampleT context m [Result])
    -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> next
-> SpecCommand context m next
IntroduceWith'' Maybe SrcLoc
loci NodeOptions
noi String
li Label l intro
cl (intro -> ExampleT context m [Result]) -> ExampleT context m ()
action (forall (m :: * -> *) context.
(Monad m, HasCallStack) =>
Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l (forall (m :: * -> *) introduce context.
Monad m =>
(ExampleT context m [Result] -> ExampleT context m ())
-> ExampleT (introduce :> context) m [Result]
-> ExampleT (introduce :> context) m ()
unwrapContext ExampleT context m [Result] -> ExampleT context m ()
f) SpecFree (LabelValue l intro :> context) m ()
subspec) (forall (m :: * -> *) context.
(Monad m, HasCallStack) =>
Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f Free (SpecCommand context m) ()
next))
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f (Free (Introduce'' Maybe SrcLoc
loci NodeOptions
noi String
li Label l intro
cl ExampleT context m intro
alloc intro -> ExampleT context m ()
clean SpecFree (LabelValue l intro :> context) m ()
subspec Free (SpecCommand context m) ()
next)) = forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (forall l (intro :: Symbol) context (m :: * -> *) next.
Typeable l =>
Maybe SrcLoc
-> NodeOptions
-> String
-> Label intro l
-> ExampleT context m l
-> (l -> ExampleT context m ())
-> SpecFree (LabelValue intro l :> context) m ()
-> next
-> SpecCommand context m next
Introduce'' Maybe SrcLoc
loci NodeOptions
noi String
li Label l intro
cl ExampleT context m intro
alloc intro -> ExampleT context m ()
clean (forall (m :: * -> *) context.
(Monad m, HasCallStack) =>
Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l (forall (m :: * -> *) introduce context.
Monad m =>
(ExampleT context m [Result] -> ExampleT context m ())
-> ExampleT (introduce :> context) m [Result]
-> ExampleT (introduce :> context) m ()
unwrapContext ExampleT context m [Result] -> ExampleT context m ()
f) SpecFree (LabelValue l intro :> context) m ()
subspec) (forall (m :: * -> *) context.
(Monad m, HasCallStack) =>
Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f Free (SpecCommand context m) ()
next))

-- * ----------------------------------------------------------

unwrapContext :: forall m introduce context. (Monad m) => (ExampleT context m [Result] -> ExampleT context m ()) -> ExampleT (introduce :> context) m [Result] -> ExampleT (introduce :> context) m ()
unwrapContext :: forall (m :: * -> *) introduce context.
Monad m =>
(ExampleT context m [Result] -> ExampleT context m ())
-> ExampleT (introduce :> context) m [Result]
-> ExampleT (introduce :> context) m ()
unwrapContext ExampleT context m [Result] -> ExampleT context m ()
f (ExampleT ReaderT (introduce :> context) (LoggingT m) [Result]
action) = do
  introduce
i :> context
_ <- forall r (m :: * -> *). MonadReader r m => m r
ask
  forall context (m :: * -> *) a.
ReaderT context (LoggingT m) a -> ExampleT context m a
ExampleT forall a b. (a -> b) -> a -> b
$ forall r' r (m :: * -> *) a.
(r' -> r) -> ReaderT r m a -> ReaderT r' m a
withReaderT (\(introduce
_ :> context
context) -> context
context) forall a b. (a -> b) -> a -> b
$ forall context (m :: * -> *) a.
ExampleT context m a -> ReaderT context (LoggingT m) a
unExampleT forall a b. (a -> b) -> a -> b
$ ExampleT context m [Result] -> ExampleT context m ()
f forall a b. (a -> b) -> a -> b
$ forall context (m :: * -> *) a.
ReaderT context (LoggingT m) a -> ExampleT context m a
ExampleT (forall r' r (m :: * -> *) a.
(r' -> r) -> ReaderT r m a -> ReaderT r' m a
withReaderT (introduce
i forall a b. a -> b -> a :> b
:>) ReaderT (introduce :> context) (LoggingT m) [Result]
action)


-- | Convert a spec to a run tree
alterTopLevelNodeOptions :: (NodeOptions -> NodeOptions) -> Free (SpecCommand context IO) r -> Free (SpecCommand context IO) r
alterTopLevelNodeOptions :: forall context r.
(NodeOptions -> NodeOptions)
-> Free (SpecCommand context IO) r
-> Free (SpecCommand context IO) r
alterTopLevelNodeOptions NodeOptions -> NodeOptions
g (Free SpecCommand context IO (Free (SpecCommand context IO) r)
x) = forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context IO (Free (SpecCommand context IO) r)
x { nodeOptions :: NodeOptions
nodeOptions = NodeOptions -> NodeOptions
g (forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
nodeOptions SpecCommand context IO (Free (SpecCommand context IO) r)
x)
                                              , next :: Free (SpecCommand context IO) r
next = forall context r.
(NodeOptions -> NodeOptions)
-> Free (SpecCommand context IO) r
-> Free (SpecCommand context IO) r
alterTopLevelNodeOptions NodeOptions -> NodeOptions
g (forall context (m :: * -> *) next.
SpecCommand context m next -> next
next SpecCommand context IO (Free (SpecCommand context IO) r)
x)})
alterTopLevelNodeOptions NodeOptions -> NodeOptions
_ x :: Free (SpecCommand context IO) r
x@(Pure r
_) = Free (SpecCommand context IO) r
x

systemVisibilityThreshold :: Int
systemVisibilityThreshold :: Int
systemVisibilityThreshold = Int
150