{-# OPTIONS_HADDOCK show-extensions #-}
module Test.Fluent.Assertions.Maybe (isNothing, isJust, extracting) where
import qualified Data.Maybe as Maybe
import GHC.Stack (HasCallStack)
import Test.Fluent.Assertions
( focus,
forceError,
inside,
simpleAssertion,
)
import Test.Fluent.Internal.Assertions (Assertion, Assertion')
isNothing :: HasCallStack => Assertion (Maybe a)
isNothing :: Assertion (Maybe a)
isNothing = (Maybe a -> Bool) -> Assertion Bool -> Assertion (Maybe a)
forall b a. (b -> a) -> Assertion a -> Assertion b
inside Maybe a -> Bool
forall a. Maybe a -> Bool
Maybe.isNothing ((Bool -> Bool) -> (Bool -> String) -> Assertion Bool
forall a.
HasCallStack =>
(a -> Bool) -> (a -> String) -> Assertion a
simpleAssertion (Bool -> Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Bool
True) Bool -> String
forall p p. IsString p => p -> p
assertionMessage)
where
assertionMessage :: p -> p
assertionMessage p
_ = p
"should be Nothing"
isJust :: HasCallStack => Assertion (Maybe a)
isJust :: Assertion (Maybe a)
isJust = (Maybe a -> Bool) -> Assertion Bool -> Assertion (Maybe a)
forall b a. (b -> a) -> Assertion a -> Assertion b
inside Maybe a -> Bool
forall a. Maybe a -> Bool
Maybe.isJust ((Bool -> Bool) -> (Bool -> String) -> Assertion Bool
forall a.
HasCallStack =>
(a -> Bool) -> (a -> String) -> Assertion a
simpleAssertion (Bool -> Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Bool
True) Bool -> String
forall p p. IsString p => p -> p
assertionMessage)
where
assertionMessage :: p -> p
assertionMessage p
_ = p
"should be Just"
extracting :: HasCallStack => Assertion' (Maybe a) a
= Assertion (Maybe a) -> Assertion (Maybe a)
forall a. Assertion a -> Assertion a
forceError Assertion (Maybe a)
forall a. HasCallStack => Assertion (Maybe a)
isJust Assertion (Maybe a)
-> Assertion' (Maybe a) a -> Assertion' (Maybe a) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe a -> a) -> Assertion' (Maybe a) a
forall a b. (a -> b) -> Assertion' a b
focus Maybe a -> a
forall a. HasCallStack => Maybe a -> a
Maybe.fromJust