{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ConstraintKinds #-}
module Test.Hspec.Core.Spec (
it
, specify
, describe
, context
, pending
, pendingWith
, xit
, xspecify
, xdescribe
, xcontext
, focus
, fit
, fspecify
, fdescribe
, fcontext
, parallel
, sequential
, Test.Hspec.Core.Spec.Monad.Spec
, Test.Hspec.Core.Spec.Monad.SpecWith
, Test.Hspec.Core.Spec.Monad.SpecM(..)
, Test.Hspec.Core.Spec.Monad.runSpecM
, Test.Hspec.Core.Spec.Monad.fromSpecList
, Test.Hspec.Core.Spec.Monad.runIO
, Test.Hspec.Core.Spec.Monad.mapSpecForest
, Test.Hspec.Core.Spec.Monad.mapSpecItem
, Test.Hspec.Core.Spec.Monad.mapSpecItem_
, Test.Hspec.Core.Spec.Monad.modifyParams
, Test.Hspec.Core.Spec.Monad.modifyConfig
, getSpecDescriptionPath
, Test.Hspec.Core.Example.Example (..)
, Test.Hspec.Core.Example.Params (..)
, Test.Hspec.Core.Example.defaultParams
, Test.Hspec.Core.Example.ActionWith
, Test.Hspec.Core.Example.Progress
, Test.Hspec.Core.Example.ProgressCallback
, Test.Hspec.Core.Example.Result(..)
, Test.Hspec.Core.Example.ResultStatus (..)
, Test.Hspec.Core.Example.Location (..)
, Test.Hspec.Core.Example.FailureReason (..)
, Test.Hspec.Core.Example.safeEvaluate
, Test.Hspec.Core.Example.safeEvaluateExample
, Test.Hspec.Core.Tree.SpecTree
, Test.Hspec.Core.Tree.Tree (..)
, Test.Hspec.Core.Tree.Item (..)
, Test.Hspec.Core.Tree.specGroup
, Test.Hspec.Core.Tree.specItem
, Test.Hspec.Core.Tree.bimapTree
, Test.Hspec.Core.Tree.bimapForest
, Test.Hspec.Core.Tree.filterTree
, Test.Hspec.Core.Tree.filterForest
, Test.Hspec.Core.Tree.filterTreeWithLabels
, Test.Hspec.Core.Tree.filterForestWithLabels
, Test.Hspec.Core.Tree.pruneTree
, Test.Hspec.Core.Tree.pruneForest
, Test.Hspec.Core.Tree.location
, focusForest
) where
import Prelude ()
import Test.Hspec.Core.Compat
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Reader (asks)
import Test.Hspec.Expectations (Expectation)
import Test.Hspec.Core.Example
import Test.Hspec.Core.Hooks
import Test.Hspec.Core.Tree
import Test.Hspec.Core.Spec.Monad
describe :: HasCallStack => String -> SpecWith a -> SpecWith a
describe :: forall a. HasCallStack => String -> SpecWith a -> SpecWith a
describe String
label = forall a r. (Env -> Env) -> SpecM a r -> SpecM a r
withEnv Env -> Env
pushLabel forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b r.
([SpecTree a] -> [SpecTree b]) -> SpecM a r -> SpecM b r
mapSpecForest (forall (m :: * -> *) a. Monad m => a -> m a
return forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. HasCallStack => String -> [SpecTree a] -> SpecTree a
specGroup String
label)
where
pushLabel :: Env -> Env
pushLabel (Env [String]
labels) = [String] -> Env
Env forall a b. (a -> b) -> a -> b
$ String
label forall a. a -> [a] -> [a]
: [String]
labels
context :: HasCallStack => String -> SpecWith a -> SpecWith a
context :: forall a. HasCallStack => String -> SpecWith a -> SpecWith a
context = forall a. HasCallStack => String -> SpecWith a -> SpecWith a
describe
xdescribe :: HasCallStack => String -> SpecWith a -> SpecWith a
xdescribe :: forall a. HasCallStack => String -> SpecWith a -> SpecWith a
xdescribe String
label SpecWith a
spec = forall a. IO () -> SpecWith a -> SpecWith a
before_ IO ()
pending_ forall a b. (a -> b) -> a -> b
$ forall a. HasCallStack => String -> SpecWith a -> SpecWith a
describe String
label SpecWith a
spec
xcontext :: HasCallStack => String -> SpecWith a -> SpecWith a
xcontext :: forall a. HasCallStack => String -> SpecWith a -> SpecWith a
xcontext = forall a. HasCallStack => String -> SpecWith a -> SpecWith a
xdescribe
it :: (HasCallStack, Example a) => String -> a -> SpecWith (Arg a)
it :: forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
it String
label a
action = forall a. [SpecTree a] -> SpecWith a
fromSpecList [forall a.
(HasCallStack, Example a) =>
String -> a -> SpecTree (Arg a)
specItem String
label a
action]
specify :: (HasCallStack, Example a) => String -> a -> SpecWith (Arg a)
specify :: forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
specify = forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
it
xit :: (HasCallStack, Example a) => String -> a -> SpecWith (Arg a)
xit :: forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
xit String
label a
action = forall a. IO () -> SpecWith a -> SpecWith a
before_ IO ()
pending_ forall a b. (a -> b) -> a -> b
$ forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
it String
label a
action
xspecify :: (HasCallStack, Example a) => String -> a -> SpecWith (Arg a)
xspecify :: forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
xspecify = forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
xit
focus :: SpecWith a -> SpecWith a
focus :: forall a. SpecWith a -> SpecWith a
focus = forall a b r.
([SpecTree a] -> [SpecTree b]) -> SpecM a r -> SpecM b r
mapSpecForest forall a. [SpecTree a] -> [SpecTree a]
focusForest
focusForest :: [SpecTree a] -> [SpecTree a]
focusForest :: forall a. [SpecTree a] -> [SpecTree a]
focusForest [SpecTree a]
xs
| forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any forall a. Item a -> Bool
itemIsFocused) [SpecTree a]
xs = [SpecTree a]
xs
| Bool
otherwise = forall a b c d. (a -> b) -> (c -> d) -> [Tree a c] -> [Tree b d]
bimapForest forall a. a -> a
id (\ Item a
item -> Item a
item {itemIsFocused :: Bool
itemIsFocused = Bool
True}) [SpecTree a]
xs
fit :: (HasCallStack, Example a) => String -> a -> SpecWith (Arg a)
fit :: forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
fit = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. SpecWith a -> SpecWith a
focus forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
it
fspecify :: (HasCallStack, Example a) => String -> a -> SpecWith (Arg a)
fspecify :: forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
fspecify = forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
fit
fdescribe :: HasCallStack => String -> SpecWith a -> SpecWith a
fdescribe :: forall a. HasCallStack => String -> SpecWith a -> SpecWith a
fdescribe = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. SpecWith a -> SpecWith a
focus forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. HasCallStack => String -> SpecWith a -> SpecWith a
describe
fcontext :: HasCallStack => String -> SpecWith a -> SpecWith a
fcontext :: forall a. HasCallStack => String -> SpecWith a -> SpecWith a
fcontext = forall a. HasCallStack => String -> SpecWith a -> SpecWith a
fdescribe
parallel :: SpecWith a -> SpecWith a
parallel :: forall a. SpecWith a -> SpecWith a
parallel = forall a b. (Item a -> Item b) -> SpecWith a -> SpecWith b
mapSpecItem_ (forall a. Bool -> Item a -> Item a
setParallelizable Bool
True)
sequential :: SpecWith a -> SpecWith a
sequential :: forall a. SpecWith a -> SpecWith a
sequential = forall a b. (Item a -> Item b) -> SpecWith a -> SpecWith b
mapSpecItem_ (forall a. Bool -> Item a -> Item a
setParallelizable Bool
False)
setParallelizable :: Bool -> Item a -> Item a
setParallelizable :: forall a. Bool -> Item a -> Item a
setParallelizable Bool
value Item a
item = Item a
item {itemIsParallelizable :: Maybe Bool
itemIsParallelizable = forall a. Item a -> Maybe Bool
itemIsParallelizable Item a
item forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall a. a -> Maybe a
Just Bool
value}
pending :: HasCallStack => Expectation
pending :: HasCallStack => IO ()
pending = forall e a. Exception e => e -> IO a
throwIO (Maybe Location -> Maybe String -> ResultStatus
Pending HasCallStack => Maybe Location
location forall a. Maybe a
Nothing)
pending_ :: Expectation
pending_ :: IO ()
pending_ = (forall e a. Exception e => e -> IO a
throwIO (Maybe Location -> Maybe String -> ResultStatus
Pending forall a. Maybe a
Nothing forall a. Maybe a
Nothing))
pendingWith :: HasCallStack => String -> Expectation
pendingWith :: HasCallStack => String -> IO ()
pendingWith = forall e a. Exception e => e -> IO a
throwIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe Location -> Maybe String -> ResultStatus
Pending HasCallStack => Maybe Location
location forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> Maybe a
Just
getSpecDescriptionPath :: SpecM a [String]
getSpecDescriptionPath :: forall a. SpecM a [String]
getSpecDescriptionPath = forall a r.
WriterT (Endo Config, [SpecTree a]) (ReaderT Env IO) r -> SpecM a r
SpecM forall a b. (a -> b) -> a -> b
$ forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. [a] -> [a]
reverse forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) r a. Monad m => (r -> a) -> ReaderT r m a
asks Env -> [String]
envSpecDescriptionPath