{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ViewPatterns #-}
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 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 = [Int] -> Int
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum ([Int] -> Int) -> [Int] -> Int
forall a b. (a -> b) -> a -> b
$ (RunNodeWithStatus context s l t -> Int)
-> [RunNodeWithStatus context s l t] -> [Int]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((forall context. RunNodeWithStatus context s l t -> Bool)
-> RunNodeWithStatus context s l t -> Int
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 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 context s l t.
RunNodeWithStatus context s l t -> ExampleT context IO ()
runNodeCommon :: forall context s l t.
RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
runNodeExample :: ExampleT context IO ()
runNodeCommon :: RunNodeCommonWithStatus s l t
..}) = if RunNodeWithStatus context s l t -> Bool
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 context s l t.
RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
..}) = (if RunNodeWithStatus context s l t -> Bool
forall context. RunNodeWithStatus context s l t -> Bool
p RunNodeWithStatus context s l t
rt then Int
1 else Int
0) Int -> Int -> Int
forall a. Num a => a -> a -> a
+ (forall context. RunNodeWithStatus context s l t -> Bool)
-> [RunNodeWithStatus (LabelValue lab intro :> context) s l t]
-> Int
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 context s l t.
RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
..}) = (if RunNodeWithStatus context s l t -> Bool
forall context. RunNodeWithStatus context s l t -> Bool
p RunNodeWithStatus context s l t
rt then Int
1 else Int
0) Int -> Int -> Int
forall a. Num a => a -> a -> a
+ (forall context. RunNodeWithStatus context s l t -> Bool)
-> [RunNodeWithStatus (LabelValue lab intro :> context) s l t]
-> Int
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 RunNodeWithStatus context s l t -> Bool
forall context. RunNodeWithStatus context s l t -> Bool
p RunNodeWithStatus context s l t
rt then Int
1 else Int
0) Int -> Int -> Int
forall a. Num a => a -> a -> a
+ (forall context. RunNodeWithStatus context s l t -> Bool)
-> [RunNodeWithStatus context s l t] -> Int
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
-> [RunNodeWithStatus context s l t]
forall context s l t.
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 context s l t.
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 context s l t.
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 context s l t.
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 context s l t.
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 context s l t.
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 context s l t.
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 (RunNodeWithStatus context Status l t
-> RunNodeCommonWithStatus Status l t
forall context s l t.
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 (RunNodeWithStatus context Status l t
-> RunNodeCommonWithStatus Status l t
forall context s l t.
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 context s l t.
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 context s l t.
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