easytest-0.1: Simple, expressive testing library
Safe HaskellSafe-Inferred
LanguageHaskell2010

EasyTest

Synopsis

Documentation

data Status Source #

Constructors

Failed 
Passed !Int 
Skipped 
Pending 

data Env Source #

Constructors

Env 

Instances

Instances details
MonadReader Env Test Source # 
Instance details

Defined in EasyTest

Methods

ask :: Test Env #

local :: (Env -> Env) -> Test a -> Test a #

reader :: (Env -> a) -> Test a #

newtype Test a Source #

Constructors

Test (ReaderT Env IO (Maybe a)) 

Instances

Instances details
MonadFail Test Source # 
Instance details

Defined in EasyTest

Methods

fail :: String -> Test a #

MonadIO Test Source # 
Instance details

Defined in EasyTest

Methods

liftIO :: IO a -> Test a #

Alternative Test Source # 
Instance details

Defined in EasyTest

Methods

empty :: Test a #

(<|>) :: Test a -> Test a -> Test a #

some :: Test a -> Test [a] #

many :: Test a -> Test [a] #

Applicative Test Source # 
Instance details

Defined in EasyTest

Methods

pure :: a -> Test a #

(<*>) :: Test (a -> b) -> Test a -> Test b #

liftA2 :: (a -> b -> c) -> Test a -> Test b -> Test c #

(*>) :: Test a -> Test b -> Test b #

(<*) :: Test a -> Test b -> Test a #

Functor Test Source # 
Instance details

Defined in EasyTest

Methods

fmap :: (a -> b) -> Test a -> Test b #

(<$) :: a -> Test b -> Test a #

Monad Test Source # 
Instance details

Defined in EasyTest

Methods

(>>=) :: Test a -> (a -> Test b) -> Test b #

(>>) :: Test a -> Test b -> Test b #

return :: a -> Test a #

MonadPlus Test Source # 
Instance details

Defined in EasyTest

Methods

mzero :: Test a #

mplus :: Test a -> Test a -> Test a #

MonadCatch Test Source # 
Instance details

Defined in EasyTest

Methods

catch :: (HasCallStack, Exception e) => Test a -> (e -> Test a) -> Test a #

MonadThrow Test Source # 
Instance details

Defined in EasyTest

Methods

throwM :: (HasCallStack, Exception e) => e -> Test a #

MonadReader Env Test Source # 
Instance details

Defined in EasyTest

Methods

ask :: Test Env #

local :: (Env -> Env) -> Test a -> Test a #

reader :: (Env -> a) -> Test a #

io :: IO a -> Test a Source #

expectEqual' :: (HasCallStack, Eq a, Show a) => a -> a -> Test () Source #

expectEqual :: (HasCallStack, Eq a, Show a) => a -> a -> Test () Source #

expectNotEqual :: (HasCallStack, Eq a, Show a) => a -> a -> Test () Source #

tests :: [Test ()] -> Test () Source #

runOnly :: String -> Test a -> IO () Source #

Run all tests whose scope starts with the given prefix

rerunOnly :: Int -> String -> Test a -> IO () Source #

Run all tests with the given seed and whose scope starts with the given prefix

run :: Test a -> IO () Source #

rerun :: Int -> Test a -> IO () Source #

run' :: Int -> (String -> IO ()) -> String -> Test a -> IO () Source #

scope :: String -> Test a -> Test a Source #

Label a test. Can be nested. A `.` is placed between nested scopes, so `scope "foo" . scope "bar"` is equivalent to `scope "foo.bar"`

note :: String -> Test () Source #

Log a message

note' :: Show s => s -> Test () Source #

Log a showable value

random :: Random a => Test a Source #

Generate a random value

random' :: Random a => a -> a -> Test a Source #

Generate a bounded random value. Inclusive on both sides.

char :: Test Char Source #

Generate a random Char

int :: Test Int Source #

Generate a random Int

double :: Test Double Source #

Generate a random Double

word :: Test Word Source #

Generate a random Word

int' :: Int -> Int -> Test Int Source #

Generate a random Int in the given range Note: int 0 5` includes both `0` and `5`

char' :: Char -> Char -> Test Char Source #

Generate a random Char in the given range Note: char a z' includes both `a' and `z'.

double' :: Double -> Double -> Test Double Source #

Generate a random Double in the given range Note: double 0 1` includes both `0` and `1`.

word' :: Word -> Word -> Test Word Source #

Generate a random Double in the given range Note: word 0 10` includes both `0` and `10`.

word8' :: Word8 -> Word8 -> Test Word8 Source #

Generate a random Double in the given range Note: word8 0 10` includes both `0` and `10`.

pick :: [a] -> Test a Source #

Sample uniformly from the given list of possibilities

picker :: Int -> [a] -> Int -> Maybe a Source #

listOf :: Int -> Test a -> Test [a] Source #

Alias for replicateM

listsOf :: [Int] -> Test a -> Test [[a]] Source #

Generate a list of lists of the given sizes, an alias for `sizes forM n -> listOf n gen`

pair :: Test a -> Test b -> Test (a, b) Source #

Alias for `liftA2 (,)`.

tuple2 :: (Random a, Random b) => Test (a, b) Source #

Alias for pair.

tuple3 :: (Random a, Random b, Random c) => Test (a, b, c) Source #

Generate a random 3-tuple.

tuple4 :: (Random a, Random b, Random c, Random d) => Test (a, b, c, d) Source #

Generate a random 4-tuple.

mapOf :: Ord k => Int -> Test k -> Test v -> Test (Map k v) Source #

Generate a `Data.Map k v` of the given size.

mapsOf :: Ord k => [Int] -> Test k -> Test v -> Test [Map k v] Source #

Generate a `[Data.Map k v]` of the given sizes.

wrap :: Test a -> Test a Source #

Catch all exceptions that could occur in the given Test

using :: IO r -> (r -> IO ()) -> (r -> Test a) -> Test a Source #

A test with a setup and teardown

currentScope :: Test String Source #

The current scope

noteScoped :: String -> Test () Source #

Prepend the current scope to a logging message

ok :: Test () Source #

Record a successful test at the current scope

done :: Test a Source #

Skip any tests depending on the return value.

skip :: Test () Source #

Explicitly skip this test

crash :: HasCallStack => String -> Test a Source #

Record a failure at the current scope

nologging :: HasCallStack => Test a -> Test a Source #

Overwrites the env so that note_ (the logger) is a no op

attempt :: Test a -> Test (Maybe a) Source #

Run a test under a new scope, without logs and suppressing all output

pending :: HasCallStack => Test a -> Test a Source #

Placeholder wrapper for a failing test. The test being wrapped is expected/known to fail. Will produce a failure if the test being wrapped suddenly becomes a success.

fork :: Test a -> Test () Source #

Run a test in a separate thread, not blocking for its result.

fork' :: Test a -> Test (Test a) Source #

Run a test in a separate thread, return a future which can be used to block on its result.