hledger-lib-1.12: Core data types, parsers and functionality for the hledger accounting tools

Safe HaskellNone
LanguageHaskell2010

Hledger.Utils.Test

Synopsis

Documentation

type HasCallStack = ?callStack :: CallStack Source #

Request a CallStack.

NOTE: The implicit parameter ?callStack :: CallStack is an implementation detail and should not be considered part of the CallStack API, we may decide to change the implementation in the future.

Since: base-4.9.0.0

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

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

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

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

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

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

pick :: [a] -> Test a #

random :: Random a => Test a #

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

note :: Text -> Test () #

scope :: Text -> Test a -> Test a #

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

expectLeft :: (Show a, HasCallStack) => Either e a -> Test () #

expectRight :: (Show e, HasCallStack) => Either e a -> Test () #

fork :: Test a -> Test () #

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

io :: IO a -> Test a #

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

ok :: Test () #

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

rerunOnly :: Int -> Text -> Test a -> IO () #

run :: Test a -> IO () #

runOnly :: Text -> Test a -> IO () #

skip :: Test () #

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

data Test a #

Instances
Monad Test 
Instance details

Defined in EasyTest.Internal

Methods

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

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

return :: a -> Test a Source #

fail :: String -> Test a Source #

Functor Test 
Instance details

Defined in EasyTest.Internal

Methods

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

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

Applicative Test 
Instance details

Defined in EasyTest.Internal

Methods

pure :: a -> Test a Source #

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

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

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

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

MonadIO Test 
Instance details

Defined in EasyTest.Internal

Methods

liftIO :: IO a -> Test a Source #

Alternative Test 
Instance details

Defined in EasyTest.Internal

Methods

empty :: Test a Source #

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

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

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

MonadPlus Test 
Instance details

Defined in EasyTest.Internal

Methods

mzero :: Test a Source #

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

MonadReader Env Test 
Instance details

Defined in EasyTest.Internal

Methods

ask :: Test Env Source #

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

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

IsString (Test a -> Test a) 
Instance details

Defined in EasyTest.Internal

Methods

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

runEasytests :: [String] -> Test () -> IO Bool Source #

Run some easytest tests, catching easytest's ExitCode exception, returning True if there was a problem. With arguments, runs only the scope (or single test) named by the first argument (exact, case sensitive). If there is a second argument, it should be an integer and will be used as the seed for randomness.

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

Name and group a list of tests. Combines easytest's "scope" and "tests".

_tests :: Text -> [Test ()] -> Test () Source #

Skip the given list of tests, and any following tests in a monadic sequence, with the same type signature as "group".

test :: Text -> Test a -> Test a Source #

Name the given test(s). A readability synonym for easytest's "scope".

_test :: Text -> Test a -> Test a Source #

Skip the given test(s), with the same type signature as "test". If called in a monadic sequence of tests, also skips following tests.

it :: Text -> Test a -> Test a Source #

Name the given test(s). A synonym for "test".

_it :: Text -> Test a -> Test a Source #

Skip the given test(s), and any following tests in a monadic sequence. A synonym for "_test".

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

Shorter and flipped version of expectEqPP. The expected value goes last.

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

Like easytest's expectEq (asserts the second (actual) value equals the first (expected) value) but pretty-prints the values in the failure output.

expectParse :: (Monoid st, Eq a, Show a, HasCallStack) => StateT st (ParsecT CustomErr Text IO) a -> Text -> Test () Source #

Test that this stateful parser runnable in IO successfully parses all of the given input text, showing the parse error if it fails.

expectParseE :: (Monoid st, Eq a, Show a, HasCallStack) => StateT st (ParsecT CustomErr Text (ExceptT FinalParseError IO)) a -> Text -> Test () Source #

expectParseError :: (Monoid st, Eq a, Show a, HasCallStack) => StateT st (ParsecT CustomErr Text IO) a -> Text -> String -> Test () Source #

Test that this stateful parser runnable in IO fails to parse the given input text, with a parse error containing the given string.

expectParseErrorE :: (Monoid st, Eq a, Show a, HasCallStack) => StateT st (ParsecT CustomErr Text (ExceptT FinalParseError IO)) a -> Text -> String -> Test () Source #

expectParseEq :: (Monoid st, Eq a, Show a, HasCallStack) => StateT st (ParsecT CustomErr Text IO) a -> Text -> a -> Test () Source #

Like expectParse, but also test the parse result is an expected value, pretty-printing both if it fails.

expectParseEqE :: (Monoid st, Eq a, Show a, HasCallStack) => StateT st (ParsecT CustomErr Text (ExceptT FinalParseError IO)) a -> Text -> a -> Test () Source #

expectParseEqOn :: (Monoid st, Eq b, Show b, HasCallStack) => StateT st (ParsecT CustomErr Text IO) a -> Text -> (a -> b) -> b -> Test () Source #

Like expectParseEq, but transform the parse result with the given function before comparing it.

expectParseEqOnE :: (Monoid st, Eq b, Show b, HasCallStack) => StateT st (ParsecT CustomErr Text (ExceptT FinalParseError IO)) a -> Text -> (a -> b) -> b -> Test () Source #