module Test.TLT.Results where
data TestFail = Asserted String
| Erred String
formatFail :: TestFail -> String
formatFail :: TestFail -> String
formatFail (Asserted String
s) = String
s
formatFail (Erred String
s) = String
"Assertion raised exception: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
s
data TestResult = Test String [TestFail]
| Group String Int Int [TestResult]
failCount :: TestResult -> Int
failCount :: TestResult -> Int
failCount (Test String
_ []) = Int
0
failCount (Test String
_ [TestFail]
_) = Int
1
failCount (Group String
_ Int
_ Int
n [TestResult]
_) = Int
n
testCount :: TestResult -> Int
testCount :: TestResult -> Int
testCount (Test String
_ [TestFail]
_) = Int
1
testCount (Group String
_ Int
n Int
_ [TestResult]
_) = Int
n
totalFailCount :: [TestResult] -> Int
totalFailCount :: [TestResult] -> Int
totalFailCount = (Int -> Int -> Int) -> Int -> [Int] -> Int
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr Int -> Int -> Int
forall a. Num a => a -> a -> a
(+) Int
0 ([Int] -> Int) -> ([TestResult] -> [Int]) -> [TestResult] -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TestResult -> Int) -> [TestResult] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map TestResult -> Int
failCount
totalTestCount :: [TestResult] -> Int
totalTestCount :: [TestResult] -> Int
totalTestCount = (Int -> Int -> Int) -> Int -> [Int] -> Int
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr Int -> Int -> Int
forall a. Num a => a -> a -> a
(+) Int
0 ([Int] -> Int) -> ([TestResult] -> [Int]) -> [TestResult] -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TestResult -> Int) -> [TestResult] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map TestResult -> Int
testCount