{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE IncoherentInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -fno-warn-redundant-constraints #-}
module Test.Syd.Def.Specify
(
describe,
it,
itWithOuter,
itWithBoth,
itWithAll,
specify,
specifyWithOuter,
specifyWithBoth,
specifyWithAll,
xdescribe,
xit,
xitWithOuter,
xitWithBoth,
xitWithAll,
xspecify,
xspecifyWithOuter,
xspecifyWithBoth,
xspecifyWithAll,
pending,
pendingWith,
)
where
import Control.Monad.RWS.Strict
import qualified Data.Text as T
import GHC.Stack
import Test.QuickCheck.IO ()
import Test.Syd.Def.TestDefM
import Test.Syd.HList
import Test.Syd.Run
import Test.Syd.SpecDef
describe :: String -> TestDefM a b () -> TestDefM a b ()
describe :: String -> TestDefM a b () -> TestDefM a b ()
describe String
s TestDefM a b ()
func = ([SpecDefTree a b ()] -> [SpecDefTree a b ()])
-> TestDefM a b () -> TestDefM a b ()
forall w (m :: * -> *) a. MonadWriter w m => (w -> w) -> m a -> m a
censor ((SpecDefTree a b () -> [SpecDefTree a b ()] -> [SpecDefTree a b ()]
forall a. a -> [a] -> [a]
: []) (SpecDefTree a b () -> [SpecDefTree a b ()])
-> ([SpecDefTree a b ()] -> SpecDefTree a b ())
-> [SpecDefTree a b ()]
-> [SpecDefTree a b ()]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> [SpecDefTree a b ()] -> SpecDefTree a b ()
forall (a :: [*]) c e.
Text -> SpecDefForest a c e -> SpecDefTree a c e
DefDescribeNode (String -> Text
T.pack String
s)) TestDefM a b ()
func
xdescribe :: String -> TestDefM a b () -> TestDefM a b ()
xdescribe :: String -> TestDefM a b () -> TestDefM a b ()
xdescribe String
s TestDefM a b ()
_ = String -> TestDefM a b ()
forall (a :: [*]) b. String -> TestDefM a b ()
pending String
s
it :: forall outers test. (HasCallStack, IsTest test, Arg1 test ~ ()) => String -> test -> TestDefM outers (Arg2 test) ()
it :: String -> test -> TestDefM outers (Arg2 test) ()
it String
s test
t = do
TestRunSettings
sets <- TestDefM outers (Arg2 test) TestRunSettings
forall r (m :: * -> *). MonadReader r m => m r
ask
let testDef :: TDef
(((HList outers -> Arg2 test -> IO ()) -> IO ())
-> IO TestRunResult)
testDef =
TDef :: forall v. v -> CallStack -> TDef v
TDef
{ testDefVal :: ((HList outers -> Arg2 test -> IO ()) -> IO ()) -> IO TestRunResult
testDefVal = \(HList outers -> Arg2 test -> IO ()) -> IO ()
supplyArgs ->
test
-> TestRunSettings
-> ((Arg1 test -> Arg2 test -> IO ()) -> IO ())
-> IO TestRunResult
forall e.
IsTest e =>
e
-> TestRunSettings
-> ((Arg1 e -> Arg2 e -> IO ()) -> IO ())
-> IO TestRunResult
runTest
test
t
TestRunSettings
sets
( \Arg1 test -> Arg2 test -> IO ()
func -> (HList outers -> Arg2 test -> IO ()) -> IO ()
supplyArgs (\HList outers
_ Arg2 test
arg2 -> Arg1 test -> Arg2 test -> IO ()
func () Arg2 test
arg2)
),
testDefCallStack :: CallStack
testDefCallStack = CallStack
HasCallStack => CallStack
callStack
}
[SpecDefTree outers (Arg2 test) ()]
-> TestDefM outers (Arg2 test) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell [Text
-> TDef
(((HList outers -> Arg2 test -> IO ()) -> IO ())
-> IO TestRunResult)
-> ()
-> SpecDefTree outers (Arg2 test) ()
forall (a :: [*]) c e.
Text
-> TDef (((HList a -> c -> IO ()) -> IO ()) -> IO TestRunResult)
-> e
-> SpecDefTree a c e
DefSpecifyNode (String -> Text
T.pack String
s) TDef
(((HList outers -> Arg2 test -> IO ()) -> IO ())
-> IO TestRunResult)
testDef ()]
xit :: forall outers test. (HasCallStack, IsTest test, Arg1 test ~ ()) => String -> test -> TestDefM outers (Arg2 test) ()
xit :: String -> test -> TestDefM outers (Arg2 test) ()
xit String
s test
_ = String -> TestDefM outers (Arg2 test) ()
forall (a :: [*]) b. String -> TestDefM a b ()
pending String
s
itWithOuter :: (HasCallStack, IsTest test) => String -> test -> TestDefM (Arg2 test ': l) (Arg1 test) ()
itWithOuter :: String -> test -> TestDefM (Arg2 test : l) (Arg1 test) ()
itWithOuter String
s test
t = do
TestRunSettings
sets <- TestDefM (Arg2 test : l) (Arg1 test) TestRunSettings
forall r (m :: * -> *). MonadReader r m => m r
ask
let testDef :: TDef
(((HList (Arg2 test : l) -> Arg1 test -> IO ()) -> IO ())
-> IO TestRunResult)
testDef =
TDef :: forall v. v -> CallStack -> TDef v
TDef
{ testDefVal :: ((HList (Arg2 test : l) -> Arg1 test -> IO ()) -> IO ())
-> IO TestRunResult
testDefVal = \(HList (Arg2 test : l) -> Arg1 test -> IO ()) -> IO ()
supplyArgs ->
test
-> TestRunSettings
-> ((Arg1 test -> Arg2 test -> IO ()) -> IO ())
-> IO TestRunResult
forall e.
IsTest e =>
e
-> TestRunSettings
-> ((Arg1 e -> Arg2 e -> IO ()) -> IO ())
-> IO TestRunResult
runTest
test
t
TestRunSettings
sets
(\Arg1 test -> Arg2 test -> IO ()
func -> (HList (Arg2 test : l) -> Arg1 test -> IO ()) -> IO ()
supplyArgs ((HList (Arg2 test : l) -> Arg1 test -> IO ()) -> IO ())
-> (HList (Arg2 test : l) -> Arg1 test -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \(HCons e
outerArgs HList l
_) Arg1 test
innerArg -> Arg1 test -> Arg2 test -> IO ()
func Arg1 test
innerArg e
Arg2 test
outerArgs),
testDefCallStack :: CallStack
testDefCallStack = CallStack
HasCallStack => CallStack
callStack
}
[SpecDefTree (Arg2 test : l) (Arg1 test) ()]
-> TestDefM (Arg2 test : l) (Arg1 test) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell [Text
-> TDef
(((HList (Arg2 test : l) -> Arg1 test -> IO ()) -> IO ())
-> IO TestRunResult)
-> ()
-> SpecDefTree (Arg2 test : l) (Arg1 test) ()
forall (a :: [*]) c e.
Text
-> TDef (((HList a -> c -> IO ()) -> IO ()) -> IO TestRunResult)
-> e
-> SpecDefTree a c e
DefSpecifyNode (String -> Text
T.pack String
s) TDef
(((HList (Arg2 test : l) -> Arg1 test -> IO ()) -> IO ())
-> IO TestRunResult)
testDef ()]
xitWithOuter :: (HasCallStack, IsTest test) => String -> test -> TestDefM (Arg2 test ': l) (Arg1 test) ()
xitWithOuter :: String -> test -> TestDefM (Arg2 test : l) (Arg1 test) ()
xitWithOuter String
s test
_ = String -> TestDefM (Arg2 test : l) (Arg1 test) ()
forall (a :: [*]) b. String -> TestDefM a b ()
pending String
s
itWithBoth :: (HasCallStack, IsTest test) => String -> test -> TestDefM (Arg1 test ': l) (Arg2 test) ()
itWithBoth :: String -> test -> TestDefM (Arg1 test : l) (Arg2 test) ()
itWithBoth String
s test
t = do
TestRunSettings
sets <- TestDefM (Arg1 test : l) (Arg2 test) TestRunSettings
forall r (m :: * -> *). MonadReader r m => m r
ask
let testDef :: TDef
(((HList (Arg1 test : l) -> Arg2 test -> IO ()) -> IO ())
-> IO TestRunResult)
testDef =
TDef :: forall v. v -> CallStack -> TDef v
TDef
{ testDefVal :: ((HList (Arg1 test : l) -> Arg2 test -> IO ()) -> IO ())
-> IO TestRunResult
testDefVal = \(HList (Arg1 test : l) -> Arg2 test -> IO ()) -> IO ()
supplyArgs ->
test
-> TestRunSettings
-> ((Arg1 test -> Arg2 test -> IO ()) -> IO ())
-> IO TestRunResult
forall e.
IsTest e =>
e
-> TestRunSettings
-> ((Arg1 e -> Arg2 e -> IO ()) -> IO ())
-> IO TestRunResult
runTest
test
t
TestRunSettings
sets
(\Arg1 test -> Arg2 test -> IO ()
func -> (HList (Arg1 test : l) -> Arg2 test -> IO ()) -> IO ()
supplyArgs ((HList (Arg1 test : l) -> Arg2 test -> IO ()) -> IO ())
-> (HList (Arg1 test : l) -> Arg2 test -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \(HCons e
outerArgs HList l
_) Arg2 test
innerArg -> Arg1 test -> Arg2 test -> IO ()
func e
Arg1 test
outerArgs Arg2 test
innerArg),
testDefCallStack :: CallStack
testDefCallStack = CallStack
HasCallStack => CallStack
callStack
}
[SpecDefTree (Arg1 test : l) (Arg2 test) ()]
-> TestDefM (Arg1 test : l) (Arg2 test) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell [Text
-> TDef
(((HList (Arg1 test : l) -> Arg2 test -> IO ()) -> IO ())
-> IO TestRunResult)
-> ()
-> SpecDefTree (Arg1 test : l) (Arg2 test) ()
forall (a :: [*]) c e.
Text
-> TDef (((HList a -> c -> IO ()) -> IO ()) -> IO TestRunResult)
-> e
-> SpecDefTree a c e
DefSpecifyNode (String -> Text
T.pack String
s) TDef
(((HList (Arg1 test : l) -> Arg2 test -> IO ()) -> IO ())
-> IO TestRunResult)
testDef ()]
xitWithBoth :: (HasCallStack, IsTest test) => String -> test -> TestDefM (Arg1 test ': l) (Arg2 test) ()
xitWithBoth :: String -> test -> TestDefM (Arg1 test : l) (Arg2 test) ()
xitWithBoth String
s test
_ = String -> TestDefM (Arg1 test : l) (Arg2 test) ()
forall (a :: [*]) b. String -> TestDefM a b ()
pending String
s
itWithAll :: (HasCallStack, IsTest test, Arg1 test ~ HList l) => String -> test -> TestDefM l (Arg2 test) ()
itWithAll :: String -> test -> TestDefM l (Arg2 test) ()
itWithAll String
s test
t = do
TestRunSettings
sets <- TestDefM l (Arg2 test) TestRunSettings
forall r (m :: * -> *). MonadReader r m => m r
ask
let testDef :: TDef
(((HList l -> Arg2 test -> IO ()) -> IO ()) -> IO TestRunResult)
testDef =
TDef :: forall v. v -> CallStack -> TDef v
TDef
{ testDefVal :: ((HList l -> Arg2 test -> IO ()) -> IO ()) -> IO TestRunResult
testDefVal = \(HList l -> Arg2 test -> IO ()) -> IO ()
supplyArgs ->
test
-> TestRunSettings
-> ((Arg1 test -> Arg2 test -> IO ()) -> IO ())
-> IO TestRunResult
forall e.
IsTest e =>
e
-> TestRunSettings
-> ((Arg1 e -> Arg2 e -> IO ()) -> IO ())
-> IO TestRunResult
runTest
test
t
TestRunSettings
sets
(\Arg1 test -> Arg2 test -> IO ()
func -> (HList l -> Arg2 test -> IO ()) -> IO ()
supplyArgs HList l -> Arg2 test -> IO ()
Arg1 test -> Arg2 test -> IO ()
func),
testDefCallStack :: CallStack
testDefCallStack = CallStack
HasCallStack => CallStack
callStack
}
[SpecDefTree l (Arg2 test) ()] -> TestDefM l (Arg2 test) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell [Text
-> TDef
(((HList l -> Arg2 test -> IO ()) -> IO ()) -> IO TestRunResult)
-> ()
-> SpecDefTree l (Arg2 test) ()
forall (a :: [*]) c e.
Text
-> TDef (((HList a -> c -> IO ()) -> IO ()) -> IO TestRunResult)
-> e
-> SpecDefTree a c e
DefSpecifyNode (String -> Text
T.pack String
s) TDef
(((HList l -> Arg2 test -> IO ()) -> IO ()) -> IO TestRunResult)
testDef ()]
xitWithAll :: (HasCallStack, IsTest test, Arg1 test ~ HList l) => String -> test -> TestDefM l (Arg2 test) ()
xitWithAll :: String -> test -> TestDefM l (Arg2 test) ()
xitWithAll String
s test
_ = String -> TestDefM l (Arg2 test) ()
forall (a :: [*]) b. String -> TestDefM a b ()
pending String
s
specify :: forall outers test. (HasCallStack, IsTest test, Arg1 test ~ ()) => String -> test -> TestDefM outers (Arg2 test) ()
specify :: String -> test -> TestDefM outers (Arg2 test) ()
specify = String -> test -> TestDefM outers (Arg2 test) ()
forall (outers :: [*]) test.
(HasCallStack, IsTest test, Arg1 test ~ ()) =>
String -> test -> TestDefM outers (Arg2 test) ()
it
xspecify :: forall outers test. (HasCallStack, IsTest test, Arg1 test ~ ()) => String -> test -> TestDefM outers (Arg2 test) ()
xspecify :: String -> test -> TestDefM outers (Arg2 test) ()
xspecify = String -> test -> TestDefM outers (Arg2 test) ()
forall (outers :: [*]) test.
(HasCallStack, IsTest test, Arg1 test ~ ()) =>
String -> test -> TestDefM outers (Arg2 test) ()
xit
specifyWithOuter :: (HasCallStack, IsTest test) => String -> test -> TestDefM (Arg2 test ': l) (Arg1 test) ()
specifyWithOuter :: String -> test -> TestDefM (Arg2 test : l) (Arg1 test) ()
specifyWithOuter = String -> test -> TestDefM (Arg2 test : l) (Arg1 test) ()
forall test (l :: [*]).
(HasCallStack, IsTest test) =>
String -> test -> TestDefM (Arg2 test : l) (Arg1 test) ()
itWithOuter
xspecifyWithOuter :: (HasCallStack, IsTest test) => String -> test -> TestDefM (Arg2 test ': l) (Arg1 test) ()
xspecifyWithOuter :: String -> test -> TestDefM (Arg2 test : l) (Arg1 test) ()
xspecifyWithOuter = String -> test -> TestDefM (Arg2 test : l) (Arg1 test) ()
forall test (l :: [*]).
(HasCallStack, IsTest test) =>
String -> test -> TestDefM (Arg2 test : l) (Arg1 test) ()
xitWithOuter
specifyWithBoth :: (HasCallStack, IsTest test) => String -> test -> TestDefM (Arg1 test ': l) (Arg2 test) ()
specifyWithBoth :: String -> test -> TestDefM (Arg1 test : l) (Arg2 test) ()
specifyWithBoth = String -> test -> TestDefM (Arg1 test : l) (Arg2 test) ()
forall test (l :: [*]).
(HasCallStack, IsTest test) =>
String -> test -> TestDefM (Arg1 test : l) (Arg2 test) ()
itWithBoth
xspecifyWithBoth :: (HasCallStack, IsTest test) => String -> test -> TestDefM (Arg1 test ': l) (Arg2 test) ()
xspecifyWithBoth :: String -> test -> TestDefM (Arg1 test : l) (Arg2 test) ()
xspecifyWithBoth = String -> test -> TestDefM (Arg1 test : l) (Arg2 test) ()
forall test (l :: [*]).
(HasCallStack, IsTest test) =>
String -> test -> TestDefM (Arg1 test : l) (Arg2 test) ()
xitWithBoth
specifyWithAll :: (HasCallStack, IsTest test, Arg1 test ~ HList l) => String -> test -> TestDefM l (Arg2 test) ()
specifyWithAll :: String -> test -> TestDefM l (Arg2 test) ()
specifyWithAll = String -> test -> TestDefM l (Arg2 test) ()
forall test (l :: [*]).
(HasCallStack, IsTest test, Arg1 test ~ HList l) =>
String -> test -> TestDefM l (Arg2 test) ()
itWithAll
xspecifyWithAll :: (HasCallStack, IsTest test, Arg1 test ~ HList l) => String -> test -> TestDefM l (Arg2 test) ()
xspecifyWithAll :: String -> test -> TestDefM l (Arg2 test) ()
xspecifyWithAll = String -> test -> TestDefM l (Arg2 test) ()
forall test (l :: [*]).
(HasCallStack, IsTest test, Arg1 test ~ HList l) =>
String -> test -> TestDefM l (Arg2 test) ()
xitWithAll
pending :: String -> TestDefM a b ()
pending :: String -> TestDefM a b ()
pending String
s = [SpecDefTree a b ()] -> TestDefM a b ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell [Text -> Maybe Text -> SpecDefTree a b ()
forall (a :: [*]) c e. Text -> Maybe Text -> SpecDefTree a c e
DefPendingNode (String -> Text
T.pack String
s) Maybe Text
forall a. Maybe a
Nothing]
pendingWith :: String -> String -> TestDefM a b ()
pendingWith :: String -> String -> TestDefM a b ()
pendingWith String
s String
reason = [SpecDefTree a b ()] -> TestDefM a b ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell [Text -> Maybe Text -> SpecDefTree a b ()
forall (a :: [*]) c e. Text -> Maybe Text -> SpecDefTree a c e
DefPendingNode (String -> Text
T.pack String
s) (Text -> Maybe Text
forall a. a -> Maybe a
Just (String -> Text
T.pack String
reason))]