Karya, built on 2020-11-26T21:03:17 (patch 23b5be2d53a9e8e7d6136cda5aae2849abe5cded)
Safe HaskellNone

Util.Test.Global

Description

Exports from Util.Test.Testing. This is meant to be imported unqualified.

Synopsis

Documentation

property :: HasCallStack => PropertyT IO () -> Property #

Creates a property with the default configuration.

(/==) :: (MonadTest m, Eq a, Show a, HasCallStack) => a -> a -> m () infix 4 #

Fails the test if the two arguments provided are equal.

(===) :: (MonadTest m, Eq a, Show a, HasCallStack) => a -> a -> m () infix 4 #

Fails the test if the two arguments provided are not equal.

data ModuleMeta Source #

Constructors

ModuleMeta (IO () -> IO ()) [Tag] 

type Profile = IO () Source #

Profiles are just like tests, but I'll use a different type just for documentation at least. The real determination is that profiles start with "profile_" instead of "test_".

type Test = IO () Source #

The type of toplevel tests, which is the same as the type of individual test functions. It's just IO () for now, but some day I may be able to move to something more specialized, so if tests have declared types it might as well be one I can change in one place.

check_val :: Show a => Stack => a -> (a -> Bool) -> Test Source #

Check against a function. Use like:

check_val (f x) $ \case -> ...

equal :: (Stack, Show a, Eq a) => a -> a -> Test Source #

equal_fmt :: (Stack, Eq a, Show a) => (a -> Text) -> a -> a -> Test Source #

equal_on :: (Stack, Eq b, Show a, Show b) => (a -> b) -> a -> b -> Test Source #

Assert these things are equal after applying a function. Print without the function if they're not equal. This is for cases when the extract function loses information it would be nice to see if the test fails.

not_equal :: (Stack, Show a, Eq a) => a -> a -> Test Source #

right_equal :: (Stack, Show err, Show a, Eq a) => Either err a -> a -> Test Source #

equalf :: (Stack, Show a, ApproxEq a) => Double -> a -> a -> Test Source #

strings_like :: forall txt. (Stack, TextLike txt) => [txt] -> [Pattern] -> Test Source #

Strings in the first list match patterns in the second list, using pattern_matches.

left_like :: (Stack, Show a, TextLike txt) => Either txt a -> Pattern -> Test Source #

It's common for Left to be an error msg, or be something that can be converted to one.

match :: (Stack, TextLike txt) => txt -> Pattern -> Test Source #

throws :: (Stack, Show a) => a -> Pattern -> Test Source #

The given pure value should throw an exception that matches the predicate.

io_equal :: (Stack, Eq a, Show a) => IO a -> a -> Test Source #

io_human :: Stack => String -> IO a -> IO a Source #

Only a human can check these things.

expect_right :: (Stack, Show a) => Either a b -> b Source #

quickcheck :: (Stack, Testable prop) => prop -> Test Source #

Run a quickcheck property.

q_equal :: (Show a, Eq a) => a -> a -> Property Source #

equal for quickcheck.

success :: Stack => Text -> Test Source #

Print a msg with a special tag indicating a passing test.

failure :: Stack => Text -> Test Source #

Print a msg with a special tag indicating a failing test.

prettyp :: Pretty a => a -> IO () Source #

pprint :: Show a => a -> IO () Source #