Karya, built on 2023-08-29T07:47:28 (patch 7a412d5d6ba4968ca4155ef276a062ccdeb9109a)
Safe HaskellSafe-Inferred

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, HasCallStack) => a -> (a -> Bool) -> Test Source #

Check against a function. Use like:

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

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

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

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

equal_on :: (HasCallStack, 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.

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

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

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

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

left_like :: (HasCallStack, 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 :: (HasCallStack, TextLike txt) => txt -> Pattern -> Test Source #

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

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

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

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

Only a human can check these things.

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

Run a quickcheck property.

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

equal for quickcheck.

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

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

failure :: HasCallStack => 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 #