-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A set of assertion for writing more readable tests cases -- -- Please see the README on GitHub at -- https://github.com/paweln1986/assert4hs#readme @package assert4hs @version 0.0.0.1 module Test.Fluent.Diff pretty :: Show a => a -> a -> String -- | This library aims to provide a set of combinators to assert arbitrary -- nested data structures. The inspiration of this library is AssertJ for -- Java, the composition of assertions was inspired by lens -- library. -- -- Example: -- --
--   data Foo = Foo {name :: String, age :: Int} deriving (Show, Eq)
--   
--   assertThat (Foo "someName" 15) $
--        isEqualTo (Foo "someN1ame" 15)
--        . focus age
--        . tag "age"
--        . isGreaterThan 20
--   
-- -- result in -- --
--   given Foo {name = "someName", age = 15} should be equal to Foo {name = "someN1ame", age = 15}
--   Foo {name = "someName", age = 15}
--   ╷
--   │
--   ╵
--   Foo {name = "someN1ame", age = 15}
--                     ▲
--   [age] given 15 should be greater than 20
--   
module Test.Fluent.Assertions -- | The simpleAssertion function is a building block of more -- complicated assertions. -- -- It takes one predicate and function to format error message. -- --
--   myIsEqual x = simpleAssertion (== x) (\x' -> show x' <> " is not equal to " <> show x)
--   
simpleAssertion :: HasCallStack => (a -> Bool) -> (a -> String) -> Assertion a -- | assert if subject under test is equal to given value -- --
--   assertThat 15 $ isEqualTo 16
--   
-- -- result -- --
--   given 15 should be equal to 16
--    ▼
--   15
--   ╷
--   │
--   ╵
--   16
--    ▲
--   
isEqualTo :: (Eq a, Show a, HasCallStack) => a -> Assertion a isNotEqualTo :: (Eq a, Show a, HasCallStack) => a -> Assertion a -- | assert if the subject under test is greater than given value -- --
--   assertThat 15 $ isGreaterThan 16
--   
-- -- result -- --
--   given 15 should be greater than 16
--   
isGreaterThan :: (Ord a, Show a, HasCallStack) => a -> Assertion a isGreaterEqualThan :: (Ord a, Show a, HasCallStack) => a -> Assertion a -- | assert if the subject under test is lower than given value -- --
--   assertThat 16 $ isLowerThan 15
--   
-- -- result -- --
--   given 16 should be lower than 15
--   
isLowerThan :: (Ord a, Show a, HasCallStack) => a -> Assertion a isLowerEqualThan :: (Ord a, Show a, HasCallStack) => a -> Assertion a shouldSatisfy :: (Show a, HasCallStack) => (a -> Bool) -> Assertion a hasSize :: (Foldable t, HasCallStack) => Int -> Assertion (t a) isEmpty :: (Foldable t, HasCallStack) => Assertion (t a) isNotEmpty :: (Foldable t, HasCallStack) => Assertion (t a) contains :: (Foldable t, Eq a, Show a, HasCallStack) => a -> Assertion (t a) -- | allow changing subject under test using a transformation function -- --
--   assertThat "1    " $
--             isNotEqualTo ""
--               . focus length
--               . isEqualTo 10
--   
-- -- result -- --
--   given 5 should be equal to 10
--   ▼
--   5
--   ╷
--   │
--   ╵
--   10
--   ▲▲
--   
focus :: (a -> b) -> Assertion' a b -- | like focus, this function allow changing subject under test, it -- takes an assertion for modified value, then it allows us to continue -- assertion on the original value -- --
--   assertThat (Foo "someName" 15) $
--                 isEqualTo (Foo "someN1ame" 15)
--               . inside age (tag "age" . isGreaterThan 20 . isLowerThan 10)
--               . isEqualTo (Foo "someName" 15)
--   
-- -- result -- --
--   given Foo {name = "someName", age = 15} should be equal to Foo {name = "someN1ame", age = 15}
--         Foo {name = "someName", age = 15}
--         ╷
--         │
--         ╵
--         Foo {name = "someN1ame", age = 15}
--                           ▲
--         [age] given 15 should be greater than 20
--         [age] given 15 should be lower than 10
--   
inside :: (b -> a) -> Assertion a -> Assertion b -- | this combinator allows marking following assertion with a given prefix -- --
--   assertThat (Foo "someName" 15) $
--     tag "foo" . isEqualTo (Foo "someN1ame" 15)
--       . inside age (tag "age" . isGreaterThan 20 . isLowerThan 10)
--       . tag "foo not equal"
--       . isNotEqualTo (Foo "someName" 15)
--   
-- -- result -- --
--   [foo] given Foo {name = "someName", age = 15} should be equal to Foo {name = "someN1ame", age = 15}
--   Foo {name = "someName", age = 15}
--   ╷
--   │
--   ╵
--   Foo {name = "someN1ame", age = 15}
--                     ▲
--   [foo.age] given 15 should be greater than 20
--   [foo.age] given 15 should be lower than 10
--   [foo.not equal to] given Foo {name = "someName", age = 15} should be not equal to Foo {name = "someName", age = 15}
--   Foo {name = "someName", age = 15}
--   ╷
--   │
--   ╵
--   Foo {name = "someName", age = 15}
--   
tag :: String -> Assertion a forceError :: Assertion a -> Assertion a assertThat :: HasCallStack => a -> Assertion' a b -> IO () type Assertion a = Assertion' a a type Assertion' a b = Assertion'' a a b b data FluentTestFailure FluentTestFailure :: !Maybe SrcLoc -> ![(String, Maybe SrcLoc)] -> !Int -> !Int -> FluentTestFailure [srcLoc] :: FluentTestFailure -> !Maybe SrcLoc [msg] :: FluentTestFailure -> ![(String, Maybe SrcLoc)] [errorsCount] :: FluentTestFailure -> !Int [successCount] :: FluentTestFailure -> !Int -- | This library aims to provide a set of combinators to assert Maybe -- type. module Test.Fluent.Assertions.Maybe -- | assert if subject under is empty -- --
--   assertThat (Just 10) isNothing
--   
isNothing :: HasCallStack => Assertion (Maybe a) -- | assert if subject under is not empty -- --
--   assertThat (Just 10) isJust
--   
isJust :: HasCallStack => Assertion (Maybe a) -- | assert if subject under is not empty and extract contained value -- --
--   assertThat (Just 10) extracting
--   
extracting :: HasCallStack => Assertion' (Maybe a) a -- | This mudule provide an assertion for check if expected Exception has -- been throw by IO action. module Test.Fluent.Assertions.Exceptions assertThrowing :: (HasCallStack, Exception e) => IO a -> ExceptionSelector e -> Assertion' e b -> IO () assertThrowing' :: (HasCallStack, Exception e) => IO a -> ExceptionSelector e -> IO () -- | Select all exceptions. anyException :: ExceptionSelector SomeException -- | Select all IOException. anyIOException :: ExceptionSelector IOException -- | Select all an Exception of given type. This selector should be used -- with TypeApplications -- --
--   data MyException = ThisException | ThatException
--    deriving (Show)
--   
--   instance Exception MyException
--   
--   selectMyException = exceptionType @MyException
--   
exceptionOfType :: Exception e => ExceptionSelector e type ExceptionSelector a = a -> a -- | This module provide a set of combinators to assert Either type. module Test.Fluent.Assertions.Either -- | assert if subject under test is Left -- --
--   assertThat (Left 10) isLeft
--   
isLeft :: HasCallStack => Assertion (Either a b) -- | assert if subject under test is Right -- --
--   assertThat (Left 10) isRight
--   
isRight :: HasCallStack => Assertion (Either a b) -- | assert if subject under test is Right and extract contained value -- --
--   assertThat (Left 10) extractingRight
--   
extractingRight :: HasCallStack => Assertion' (Either a b) b -- | assert if subject under test is Left and extract contained value -- --
--   assertThat (Left 10) extractingLeft
--   
extractingLeft :: HasCallStack => Assertion' (Either a b) a