Split kind tests into component-owned probes
This commit is contained in:
parent
b3c0f6d58a
commit
691ad92e30
1 changed files with 4269 additions and 3108 deletions
27
test/Nuthatch/Probe/Assert.hs
Normal file
27
test/Nuthatch/Probe/Assert.hs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
module Nuthatch.Probe.Assert
|
||||
( assert
|
||||
, assertContains
|
||||
, assertEqual
|
||||
, requireEnv
|
||||
) where
|
||||
|
||||
import Control.Monad (unless)
|
||||
import qualified Data.ByteString as BS
|
||||
import System.Environment (lookupEnv)
|
||||
|
||||
assert :: String -> Bool -> IO ()
|
||||
assert label condition =
|
||||
unless condition (fail label)
|
||||
|
||||
assertContains :: String -> BS.ByteString -> BS.ByteString -> IO ()
|
||||
assertContains label needle haystack =
|
||||
assert label (needle `BS.isInfixOf` haystack)
|
||||
|
||||
assertEqual :: (Eq value, Show value) => String -> value -> value -> IO ()
|
||||
assertEqual label expected actual =
|
||||
unless (actual == expected) $
|
||||
fail (label <> ": expected " <> show expected <> ", got " <> show actual)
|
||||
|
||||
requireEnv :: String -> IO String
|
||||
requireEnv name =
|
||||
lookupEnv name >>= maybe (fail ("missing " <> name)) pure
|
||||
Loading…
Reference in a new issue