Safe Haskell | Safe-Inferred |
---|
Exports from Util.Test.Testing. This is meant to be imported unqualified.
Synopsis
- property :: HasCallStack => PropertyT IO () -> Property
- (/==) :: (MonadTest m, Eq a, Show a, HasCallStack) => a -> a -> m ()
- (===) :: (MonadTest m, Eq a, Show a, HasCallStack) => a -> a -> m ()
- data ModuleMeta = ModuleMeta (IO () -> IO ()) [Tag]
- type Profile = IO ()
- type Test = IO ()
- check :: HasCallStack => Text -> Bool -> Test
- check_val :: (Show a, HasCallStack) => a -> (a -> Bool) -> Test
- equal :: (HasCallStack, Show a, Eq a) => a -> a -> Test
- not_equal :: (HasCallStack, Show a, Eq a) => a -> a -> Test
- equal_fmt :: (HasCallStack, Eq a, Show a) => (a -> Text) -> a -> a -> Test
- equal_on :: (HasCallStack, Eq b, Show a, Show b) => (a -> b) -> a -> b -> Test
- right_equal :: (HasCallStack, Show err, Show a, Eq a) => Either err a -> a -> Test
- equalf :: (HasCallStack, Show a, ApproxEq a) => Double -> a -> a -> Test
- strings_like :: forall txt. (HasCallStack, TextLike txt) => [txt] -> [Pattern] -> Test
- left_like :: (HasCallStack, Show a, TextLike txt) => Either txt a -> Pattern -> Test
- match :: (HasCallStack, TextLike txt) => txt -> Pattern -> Test
- throws :: (HasCallStack, Show a) => a -> Pattern -> Test
- io_equal :: (HasCallStack, Eq a, Show a) => IO a -> a -> Test
- io_human :: HasCallStack => String -> IO a -> IO a
- pause :: String -> IO ()
- expect_right :: (HasCallStack, Show a) => Either a b -> b
- hedgehog :: Property -> Test
- quickcheck :: (HasCallStack, Testable prop) => prop -> Test
- q_equal :: (Show a, Eq a) => a -> a -> Property
- success :: HasCallStack => Text -> Test
- failure :: HasCallStack => Text -> Test
- prettyp :: Pretty a => a -> IO ()
- pprint :: Show a => a -> IO ()
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 #
ModuleMeta (IO () -> IO ()) [Tag] |
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_".
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_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 #
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.
throws :: (HasCallStack, Show a) => a -> Pattern -> Test Source #
The given pure value should throw an exception that matches the predicate.
expect_right :: (HasCallStack, Show a) => Either a b -> b Source #
quickcheck :: (HasCallStack, Testable prop) => prop -> Test Source #
Run a quickcheck property.
success :: HasCallStack => Text -> Test Source #
Print a msg with a special tag indicating a passing test.