{-# LANGUAGE RankNTypes #-}
-- |

module Test.Sandwich.Formatters.Common.Count where

import Test.Sandwich.Types.RunTree
import Test.Sandwich.Types.Spec

countWhere :: (forall context. RunNodeWithStatus context s l t -> Bool) -> [RunNodeWithStatus context s l t] -> Int
countWhere :: forall s l t context.
(forall context. RunNodeWithStatus context s l t -> Bool)
-> [RunNodeWithStatus context s l t] -> Int
countWhere forall context. RunNodeWithStatus context s l t -> Bool
p [RunNodeWithStatus context s l t]
rts = forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall s l t context.
(forall context. RunNodeWithStatus context s l t -> Bool)
-> RunNodeWithStatus context s l t -> Int
countWhere' forall context. RunNodeWithStatus context s l t -> Bool
p) [RunNodeWithStatus context s l t]
rts
  where
    countWhere' :: (forall context. RunNodeWithStatus context s l t -> Bool) -> RunNodeWithStatus context s l t -> Int
    countWhere' :: forall s l t context.
(forall context. RunNodeWithStatus context s l t -> Bool)
-> RunNodeWithStatus context s l t -> Int
countWhere' forall context. RunNodeWithStatus context s l t -> Bool
p rt :: RunNodeWithStatus context s l t
rt@(RunNodeIt {ExampleT context IO ()
RunNodeCommonWithStatus s l t
runNodeExample :: forall s l t context.
RunNodeWithStatus context s l t -> ExampleT context IO ()
runNodeCommon :: forall s l t context.
RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
runNodeExample :: ExampleT context IO ()
runNodeCommon :: RunNodeCommonWithStatus s l t
..}) = if forall context. RunNodeWithStatus context s l t -> Bool
p RunNodeWithStatus context s l t
rt then Int
1 else Int
0
    countWhere' forall context. RunNodeWithStatus context s l t -> Bool
p rt :: RunNodeWithStatus context s l t
rt@(RunNodeIntroduce {[RunNodeWithStatus (LabelValue lab intro :> context) s l t]
ExampleT context IO intro
RunNodeCommonWithStatus s l t
intro -> ExampleT context IO ()
runNodeCleanup :: ()
runNodeAlloc :: ()
runNodeChildrenAugmented :: ()
runNodeCleanup :: intro -> ExampleT context IO ()
runNodeAlloc :: ExampleT context IO intro
runNodeChildrenAugmented :: [RunNodeWithStatus (LabelValue lab intro :> context) s l t]
runNodeCommon :: RunNodeCommonWithStatus s l t
runNodeCommon :: forall s l t context.
RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
..}) = (if forall context. RunNodeWithStatus context s l t -> Bool
p RunNodeWithStatus context s l t
rt then Int
1 else Int
0) forall a. Num a => a -> a -> a
+ forall s l t context.
(forall context. RunNodeWithStatus context s l t -> Bool)
-> [RunNodeWithStatus context s l t] -> Int
countWhere forall context. RunNodeWithStatus context s l t -> Bool
p [RunNodeWithStatus (LabelValue lab intro :> context) s l t]
runNodeChildrenAugmented
    countWhere' forall context. RunNodeWithStatus context s l t -> Bool
p rt :: RunNodeWithStatus context s l t
rt@(RunNodeIntroduceWith {[RunNodeWithStatus (LabelValue lab intro :> context) s l t]
RunNodeCommonWithStatus s l t
(intro -> ExampleT context IO [Result]) -> ExampleT context IO ()
runNodeIntroduceAction :: ()
runNodeIntroduceAction :: (intro -> ExampleT context IO [Result]) -> ExampleT context IO ()
runNodeChildrenAugmented :: [RunNodeWithStatus (LabelValue lab intro :> context) s l t]
runNodeCommon :: RunNodeCommonWithStatus s l t
runNodeChildrenAugmented :: ()
runNodeCommon :: forall s l t context.
RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
..}) = (if forall context. RunNodeWithStatus context s l t -> Bool
p RunNodeWithStatus context s l t
rt then Int
1 else Int
0) forall a. Num a => a -> a -> a
+ forall s l t context.
(forall context. RunNodeWithStatus context s l t -> Bool)
-> [RunNodeWithStatus context s l t] -> Int
countWhere forall context. RunNodeWithStatus context s l t -> Bool
p [RunNodeWithStatus (LabelValue lab intro :> context) s l t]
runNodeChildrenAugmented
    countWhere' forall context. RunNodeWithStatus context s l t -> Bool
p RunNodeWithStatus context s l t
rt = (if forall context. RunNodeWithStatus context s l t -> Bool
p RunNodeWithStatus context s l t
rt then Int
1 else Int
0) forall a. Num a => a -> a -> a
+ forall s l t context.
(forall context. RunNodeWithStatus context s l t -> Bool)
-> [RunNodeWithStatus context s l t] -> Int
countWhere forall context. RunNodeWithStatus context s l t -> Bool
p (forall s l t context.
RunNodeWithStatus context s l t
-> [RunNodeWithStatus context s l t]
runNodeChildren RunNodeWithStatus context s l t
rt)

isItBlock :: RunNodeWithStatus context s l t -> Bool
isItBlock (RunNodeIt {}) = Bool
True
isItBlock RunNodeWithStatus context s l t
_ = Bool
False

isRunningItBlock :: RunNodeWithStatus context Status l t -> Bool
isRunningItBlock (RunNodeIt {runNodeCommon :: forall s l t context.
RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
runNodeCommon=(RunNodeCommonWithStatus {runTreeStatus :: forall s l t. RunNodeCommonWithStatus s l t -> s
runTreeStatus=(Running {})})}) = Bool
True
isRunningItBlock RunNodeWithStatus context Status l t
_ = Bool
False

isSuccessItBlock :: RunNodeWithStatus context Status l t -> Bool
isSuccessItBlock (RunNodeIt {runNodeCommon :: forall s l t context.
RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
runNodeCommon=(RunNodeCommonWithStatus {runTreeStatus :: forall s l t. RunNodeCommonWithStatus s l t -> s
runTreeStatus=(Done {statusResult :: Status -> Result
statusResult=Result
Success})})}) = Bool
True
isSuccessItBlock RunNodeWithStatus context Status l t
_ = Bool
False

isPendingItBlock :: RunNodeWithStatus context Status l t -> Bool
isPendingItBlock (RunNodeIt {runNodeCommon :: forall s l t context.
RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
runNodeCommon=(RunNodeCommonWithStatus {runTreeStatus :: forall s l t. RunNodeCommonWithStatus s l t -> s
runTreeStatus=(Done {statusResult :: Status -> Result
statusResult=(Failure (Pending {}))})})}) = Bool
True
isPendingItBlock (RunNodeIt {runNodeCommon :: forall s l t context.
RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
runNodeCommon=(RunNodeCommonWithStatus {runTreeStatus :: forall s l t. RunNodeCommonWithStatus s l t -> s
runTreeStatus=(Done {statusResult :: Status -> Result
statusResult=(Failure {})})})}) = Bool
False
isPendingItBlock RunNodeWithStatus context Status l t
_ = Bool
False

isFailedItBlock :: RunNodeWithStatus context Status l t -> Bool
isFailedItBlock (RunNodeIt {runNodeCommon :: forall s l t context.
RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
runNodeCommon=(RunNodeCommonWithStatus {runTreeStatus :: forall s l t. RunNodeCommonWithStatus s l t -> s
runTreeStatus=(Done {statusResult :: Status -> Result
statusResult=(Failure (Pending {}))})})}) = Bool
False
isFailedItBlock (RunNodeIt {runNodeCommon :: forall s l t context.
RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
runNodeCommon=(RunNodeCommonWithStatus {runTreeStatus :: forall s l t. RunNodeCommonWithStatus s l t -> s
runTreeStatus=(Done {statusResult :: Status -> Result
statusResult=(Failure {})})})}) = Bool
True
isFailedItBlock RunNodeWithStatus context Status l t
_ = Bool
False

isFailedBlock :: RunNodeWithStatus context Status l t -> Bool
isFailedBlock (forall s l t context.
RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
runNodeCommon -> (RunNodeCommonWithStatus {runTreeStatus :: forall s l t. RunNodeCommonWithStatus s l t -> s
runTreeStatus=(Done {statusResult :: Status -> Result
statusResult=(Failure (Pending {}))})})) = Bool
False
isFailedBlock (forall s l t context.
RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
runNodeCommon -> (RunNodeCommonWithStatus {runTreeStatus :: forall s l t. RunNodeCommonWithStatus s l t -> s
runTreeStatus=(Done {statusResult :: Status -> Result
statusResult=(Failure {})})})) = Bool
True
isFailedBlock RunNodeWithStatus context Status l t
_ = Bool
False

isDoneItBlock :: RunNodeWithStatus context Status l t -> Bool
isDoneItBlock (RunNodeIt {runNodeCommon :: forall s l t context.
RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
runNodeCommon=(RunNodeCommonWithStatus {runTreeStatus :: forall s l t. RunNodeCommonWithStatus s l t -> s
runTreeStatus=(Done {})})}) = Bool
True
isDoneItBlock RunNodeWithStatus context Status l t
_ = Bool
False

isNotStartedItBlock :: RunNodeWithStatus context Status l t -> Bool
isNotStartedItBlock (RunNodeIt {runNodeCommon :: forall s l t context.
RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
runNodeCommon=(RunNodeCommonWithStatus {runTreeStatus :: forall s l t. RunNodeCommonWithStatus s l t -> s
runTreeStatus=(NotStarted {})})}) = Bool
True
isNotStartedItBlock RunNodeWithStatus context Status l t
_ = Bool
False