Safe Haskell | None |
---|---|
Language | Haskell2010 |
Test.HMock.Internal.State
Description
This module contains MockT and SetupMockT state functions.
Synopsis
- data Severity
- data MockState m = MockState {
- mockExpectSet :: TVar (ExpectSet (Step m))
- mockDefaults :: TVar [Step m]
- mockAllowUnexpected :: TVar [Step m]
- mockSideEffects :: TVar [Step m]
- mockAmbiguitySeverity :: TVar Severity
- mockUnexpectedSeverity :: TVar Severity
- mockUninterestingSeverity :: TVar Severity
- mockUnmetSeverity :: TVar Severity
- mockClasses :: TVar (Set TypeRep)
- mockInterestingMethods :: TVar (Set (TypeRep, String))
- mockParent :: Maybe (MockState m)
- initMockState :: MonadIO m => Maybe (MockState m) -> m (MockState m)
- allStates :: MockState m -> [MockState m]
- rootState :: MockState m -> MockState m
- newtype MockSetup m a where
- runInRootState :: MockSetup m a -> MockSetup m a
- mockSetupSTM :: STM a -> MockSetup m a
- initClassIfNeeded :: forall cls m proxy. (Mockable cls, Typeable m, MonadIO m) => proxy cls -> MockSetup m ()
- markInteresting :: forall (cls :: (Type -> Type) -> Constraint) name m proxy1 proxy2. (Typeable cls, KnownSymbol name) => proxy1 cls -> proxy2 name -> MockSetup m ()
- isInteresting :: forall (cls :: (Type -> Type) -> Constraint) name m proxy1 proxy2. (Typeable cls, KnownSymbol name) => proxy1 cls -> proxy2 name -> MockSetup m Bool
- initClassesAsNeeded :: MonadIO m => ExpectSet (Step m) -> MockSetup m ()
- newtype MockT m a where
- mapMockT :: (m a -> m b) -> MockT m a -> MockT m b
- class MockContext ctx where
- fromMockSetup :: MonadIO m => MockSetup m a -> ctx m a
- expectThisSet :: MonadIO m => ExpectSet (Step m) -> MockSetup m ()
- reportFault :: (HasCallStack, MonadIO m) => Severity -> String -> MockT m ()
Documentation
The severity for a possible problem.
Full state of a mock.
Constructors
MockState | |
Fields
|
allStates :: MockState m -> [MockState m] Source #
Gets a list of all states, starting with the innermost.
newtype MockSetup m a where Source #
Monad for setting up a mockable class. Note that even though the type looks that way, this is *not* a monad transformer. It's a very restricted environment that can only be used to set up defaults for a class.
Instances
ExpectContext MockSetup Source # | This instance allows you to add expectations from |
Defined in Test.HMock.Internal.State Methods expect :: forall (m :: Type -> Type) (cls :: (Type -> Type) -> Constraint) (name :: Symbol) r expectable. (HasCallStack, MonadIO m, MockableMethod cls name m r, Expectable cls name m r expectable) => expectable -> MockSetup m () Source # expectN :: forall (m :: Type -> Type) (cls :: (Type -> Type) -> Constraint) (name :: Symbol) r expectable. (HasCallStack, MonadIO m, MockableMethod cls name m r, Expectable cls name m r expectable) => Multiplicity -> expectable -> MockSetup m () Source # expectAny :: forall (m :: Type -> Type) (cls :: (Type -> Type) -> Constraint) (name :: Symbol) r expectable. (HasCallStack, MonadIO m, MockableMethod cls name m r, Expectable cls name m r expectable) => expectable -> MockSetup m () Source # inSequence :: forall (m :: Type -> Type). MonadIO m => (forall (ctx' :: (Type -> Type) -> Type -> Type). ExpectContext ctx' => [ctx' m ()]) -> MockSetup m () Source # inAnyOrder :: forall (m :: Type -> Type). MonadIO m => (forall (ctx' :: (Type -> Type) -> Type -> Type). ExpectContext ctx' => [ctx' m ()]) -> MockSetup m () Source # anyOf :: forall (m :: Type -> Type). MonadIO m => (forall (ctx' :: (Type -> Type) -> Type -> Type). ExpectContext ctx' => [ctx' m ()]) -> MockSetup m () Source # times :: forall (m :: Type -> Type). MonadIO m => Multiplicity -> (forall (ctx' :: (Type -> Type) -> Type -> Type). ExpectContext ctx' => ctx' m ()) -> MockSetup m () Source # consecutiveTimes :: forall (m :: Type -> Type). MonadIO m => Multiplicity -> (forall (ctx' :: (Type -> Type) -> Type -> Type). ExpectContext ctx' => ctx' m ()) -> MockSetup m () Source # | |
MockContext MockSetup Source # | |
Defined in Test.HMock.Internal.State | |
Monad (MockSetup m) Source # | |
Functor (MockSetup m) Source # | |
Applicative (MockSetup m) Source # | |
Defined in Test.HMock.Internal.State |
runInRootState :: MockSetup m a -> MockSetup m a Source #
Runs a setup action with the root state, rather than the current one.
initClassIfNeeded :: forall cls m proxy. (Mockable cls, Typeable m, MonadIO m) => proxy cls -> MockSetup m () Source #
Runs class initialization for a Mockable
class, if it hasn't been run
yet.
markInteresting :: forall (cls :: (Type -> Type) -> Constraint) name m proxy1 proxy2. (Typeable cls, KnownSymbol name) => proxy1 cls -> proxy2 name -> MockSetup m () Source #
Marks a method as "interesting". This can have implications for what happens to calls to that method.
isInteresting :: forall (cls :: (Type -> Type) -> Constraint) name m proxy1 proxy2. (Typeable cls, KnownSymbol name) => proxy1 cls -> proxy2 name -> MockSetup m Bool Source #
Determines whether a method is "interesting".
newtype MockT m a where Source #
Monad transformer for running mocks.
Instances
mapMockT :: (m a -> m b) -> MockT m a -> MockT m b Source #
Applies a function to the base monad of MockT
.
class MockContext ctx where Source #
Methods
fromMockSetup :: MonadIO m => MockSetup m a -> ctx m a Source #
Runs a MockSetup
action in this monad.
Instances
MockContext MockSetup Source # | |
Defined in Test.HMock.Internal.State | |
MockContext MockT Source # | |
Defined in Test.HMock.Internal.State |
reportFault :: (HasCallStack, MonadIO m) => Severity -> String -> MockT m () Source #
Reports a potential problem with the given Severity
.