-- | Testing reports.
module Test.Mutagen.Report
  ( -- * Testing reports
    Report (..)
  , isSuccess
  )
where

import Test.Mutagen.Property (Args)

{-------------------------------------------------------------------------------
-- * Testing reports
-------------------------------------------------------------------------------}

-- | Testing report.
data Report
  = -- | The property passed all tests.
    Success
      { Report -> Int
numPassed :: Int
      -- ^ Number of passed tests
      , Report -> Int
numDiscarded :: Int
      -- ^ Number of discarded tests
      , Report -> Int
numFailed :: Int
      -- ^ Number of failed tests
      }
  | -- | The property failed for the given arguments.
    Counterexample
      { numPassed :: Int
      -- ^ Number of passed tests
      , numDiscarded :: Int
      -- ^ Number of discarded tests
      , Report -> Args
failingArgs :: Args
      -- ^ Failing arguments
      }
  | -- | The testing loop gave up before completing all tests.
    GaveUp
      { numPassed :: Int
      -- ^ Number of passed tests
      , numDiscarded :: Int
      -- ^ Number of discarded tests
      , Report -> String
reason :: String
      -- ^ Reason for giving up
      }
  | -- | The property was expected to fail, but all tests passed.
    NoExpectedFailure
      { numPassed :: Int
      -- ^ Number of passed tests
      , numDiscarded :: Int
      -- ^ Number of discarded tests
      }
  deriving (Int -> Report -> ShowS
[Report] -> ShowS
Report -> String
(Int -> Report -> ShowS)
-> (Report -> String) -> ([Report] -> ShowS) -> Show Report
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Report -> ShowS
showsPrec :: Int -> Report -> ShowS
$cshow :: Report -> String
show :: Report -> String
$cshowList :: [Report] -> ShowS
showList :: [Report] -> ShowS
Show)

-- | Check if a report indicates a successful test run.
isSuccess :: Report -> Bool
isSuccess :: Report -> Bool
isSuccess (Success{}) = Bool
True
isSuccess Report
_ = Bool
False