packages feed

microspec 0.2.1.0 → 0.2.1.1

raw patch · 2 files changed

+27/−11 lines, 2 files

Files

Test/Microspec.hs view
@@ -21,10 +21,12 @@ --       __does 2 + 2__ --     __is commutative__ -- ---   -----+--     -----+--   Runtime: 0.00943336s --   __Successes: 3, Pending: 0, Failures: 0__ --   @ + {-# LANGUAGE      FlexibleInstances    , LambdaCase@@ -58,6 +60,7 @@  import Control.Monad import Data.Char (isSpace)+import Data.List (foldl') import Data.Maybe (mapMaybe) import Data.Time (getCurrentTime, diffUTCTime) import System.Exit (exitWith, ExitCode(ExitFailure))@@ -107,7 +110,7 @@       runTestWith args 0 test     let resultCount :: ResultCounts-       resultCount = mconcat $ map countResults results+       resultCount = joinResultList {- mconcat -} $ map countResults results    endTime <- getCurrentTime    when ((numPending resultCount + numFailures resultCount) /= 0) $       putStrLn "\n  ----- Failures and pending:\n"@@ -280,23 +283,36 @@    , numPending :: Int    } deriving (Show) +-- For later, when we don't need to import 'semigroup' for older packages:+{- -- This might not be the most efficient, but a quick idea: instance Monoid ResultCounts where-   -- TODO: semigroup/monoid?:-   mempty = ResultCounts 0 0 0-   (ResultCounts a0 b0 c0) `mappend` (ResultCounts a1 b1 c1) =-      ResultCounts (a0+a1) (b0+b1) (c0+c1)+-}+-- "mempty":+emptyResults :: ResultCounts+emptyResults =+   ResultCounts 0 0 0 +-- "mappend":+joinResults :: ResultCounts -> ResultCounts -> ResultCounts+(ResultCounts a0 b0 c0) `joinResults` (ResultCounts a1 b1 c1) =+   ResultCounts (a0+a1) (b0+b1) (c0+c1)+++-- This is obv mconcat:+joinResultList :: [ResultCounts] -> ResultCounts+joinResultList = foldl' joinResults (ResultCounts 0 0 0)+ countResults :: TestTree QC.Result -> ResultCounts countResults = \case    TestLeaf _ (Right Success{}) ->-      mempty { numSuccesses = 1 }+      emptyResults {- mempty -} { numSuccesses = 1 }    TestLeaf _ (Right _) ->-      mempty { numFailures = 1 }+      emptyResults {- mempty -} { numFailures = 1 }    TestLeaf _ (Left Pending) ->-      mempty { numPending = 1 }+      emptyResults {- mempty -} { numPending = 1 }    TestBranch _ ts ->-      mconcat $ map countResults ts+      joinResultList {- mconcat -} $ map countResults ts  instance Show (TestTree x) where  show = \case
microspec.cabal view
@@ -1,5 +1,5 @@ name:                microspec-version:             0.2.1.0+version:             0.2.1.1 synopsis:            Tiny QuickCheck test library with minimal dependencies description:            A tiny (1 module, <500 lines) property-based (and unit) testing library with minimal dependencies.