Skip to content

Commit

Permalink
Merge pull request #170 from sol/export-format-label
Browse files Browse the repository at this point in the history
Export Test.QuickCheck.Test.formatLabel
  • Loading branch information
nick8325 authored Jun 5, 2017
2 parents e1ce4c1 + 895168f commit e2c5939
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Test/QuickCheck/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -353,14 +353,19 @@ success st =
++ ")."
)
cases -> do putLine (terminal st) ":"
sequence_ [ putLine (terminal st) pt | pt <- cases ]
mapM_ (putLine $ terminal st) cases
where
allLabels =
[ showP True p ++ " " ++ x | (x, p) <- summary st ]
allLabels :: [String]
allLabels = map (formatLabel (numSuccessTests st) True) (summary st)

covers = [ ("only " ++ showP False p ++ " " ++ l ++ ", not " ++ show reqP ++ "%")
covers :: [String]
covers = [ ("only " ++ formatLabel (numSuccessTests st) False (l, p) ++ ", not " ++ show reqP ++ "%")
| (l, reqP, p) <- insufficientlyCovered st ]

formatLabel :: Int -> Bool -> (String, Double) -> String
formatLabel n pad (x, p) = showP pad p ++ " " ++ x
where
showP :: Bool -> Double -> String
showP pad p =
(if pad && p < 10 then " " else "") ++
printf "%.*f" places p ++ "%"
Expand All @@ -370,7 +375,7 @@ success st =
-- two decimal places if <= 10000 successful tests, and so on.
places :: Integer
places =
ceiling (logBase 10 (fromIntegral (numSuccessTests st)) - 2 :: Double) `max` 0
ceiling (logBase 10 (fromIntegral n) - 2 :: Double) `max` 0

labelCount :: String -> State -> Int
labelCount l st =
Expand Down

0 comments on commit e2c5939

Please sign in to comment.