HMock-0.1.0.0: A flexible mock framework for testing effectful code.
Safe HaskellNone
LanguageHaskell2010

Test.HMock.Internal.TH

Synopsis

Documentation

data MockableOptions Source #

Custom options for deriving a Mockable class.

Constructors

MockableOptions 

Fields

  • mockSuffix :: String

    Suffix to add to Action and Matcher names. Defaults to "".

  • mockVerbose :: Bool

    Whether to warn about limitations of the generated mocks. This is mostly useful temporarily for finding out why generated code doesn't match your expectations. Defaults to False.

Instances

Instances details
Default MockableOptions Source # 
Instance details

Defined in Test.HMock.Internal.TH

makeMockable :: Name -> Q [Dec] Source #

Define all instances necessary to use HMock with the given class. Equivalent to both deriveMockable and deriveForMockT.

If MyClass is a class and myMethod is one of its methods, then makeMockable MyClass generates all of the following:

If MyClass is a class and myMethod is one of its methods, then makeMockable MyClass generates everything generated by makeMockableBase, as well as a Mockable instance that does no setup.

makeMockableType :: Q Type -> Q [Dec] Source #

Define all instances necessary to use HMock with the given constraint type, which should be a class applied to zero or more type arguments. Equivalent to both deriveMockableType and deriveTypeForMockT.

See makeMockable for a list of what is generated by this splice.

makeMockableWithOptions :: MockableOptions -> Name -> Q [Dec] Source #

Define all instances necessary to use HMock with the given class. This is like makeMockable, but with the ability to specify custom options.

See makeMockable for a list of what is generated by this splice.

makeMockableTypeWithOptions :: MockableOptions -> Q Type -> Q [Dec] Source #

Define all instances necessary to use HMock with the given constraint type, which should be a class applied to zero or more type arguments. This is like makeMockableType, but with the ability to specify custom options.

See makeMockable for a list of what is generated by this splice.

makeMockableBase :: Name -> Q [Dec] Source #

Defines almost all instances necessary to use HMock with the given class. Equivalent to both deriveMockableBase and deriveForMockT.

makeMockableBaseType :: Q Type -> Q [Dec] Source #

Defines almost all instances necessary to use HMock with the given constraint type, which should be a class applied to zero or more type arguments. Equivalent to both deriveMockableBaseType and deriveTypeForMockT.

makeMockableBaseWithOptions :: MockableOptions -> Name -> Q [Dec] Source #

Defines almost all instances necessary to use HMock with the given class. This is like makeMockable, but with the ability to specify custom options.

makeMockableBaseTypeWithOptions :: MockableOptions -> Q Type -> Q [Dec] Source #

Defines almost all instances necessary to use HMock with the given constraint type, which should be a class applied to zero or more type arguments. This is like makeMockableType, but with the ability to specify custom options.

deriveMockable :: Name -> Q [Dec] Source #

Defines the Mockable instance for the given class.

If MyClass is a class and myMethod is one of its methods, then deriveMockable MyClass generates everything generated by makeMockableBase, as well as a Mockable instance that does no setup.

deriveMockableType :: Q Type -> Q [Dec] Source #

Defines the Mockable instance for the given constraint type, which should be a class applied to zero or more type arguments.

See deriveMockable for a list of what is generated by this splice.

deriveMockableWithOptions :: MockableOptions -> Name -> Q [Dec] Source #

Defines the Mockable instance for the given class. This is like deriveMockable, but with the ability to specify custom options.

See deriveMockable for a list of what is generated by this splice.

deriveMockableTypeWithOptions :: MockableOptions -> Q Type -> Q [Dec] Source #

Defines the Mockable instance for the given constraint type, which should be a class applied to zero or more type arguments. This is like deriveMockableType, but with the ability to specify custom options.

See deriveMockable for a list of what is generated by this splice.

deriveMockableBase :: Name -> Q [Dec] Source #

Defines the MockableBase instance for the given class.

If MyClass is a class and myMethod is one of its methods, then deriveMockableBase MyClass generates all of the following:

  • A MockableBase MyClass instance.
  • An associated type Action MyClass, with a constructor MyMethod.
  • An associated type Matcher MyClass, with a constructor MyMethod_.
  • An Expectable instance for Action MyClass which matches an exact set of arguments, if and only if all of myMethod's arguments have Eq and Show instances.

deriveMockableBaseType :: Q Type -> Q [Dec] Source #

Defines the MockableBase instance for the given constraint type, which should be a class applied to zero or more type arguments.

See deriveMockableBase for a list of what is generated by this splice.

deriveMockableBaseWithOptions :: MockableOptions -> Name -> Q [Dec] Source #

Defines the MockableBase instance for the given class. This is like deriveMockableBase, but with the ability to specify custom options.

See deriveMockableBase for a list of what is generated by this splice.

deriveMockableBaseTypeWithOptions :: MockableOptions -> Q Type -> Q [Dec] Source #

Defines the MockableBase instance for the given constraint type, which should be a class applied to zero or more type arguments. This is like deriveMockableBaseType, but with the ability to specify custom options.

See deriveMockableBase for a list of what is generated by this splice.

deriveForMockT :: Name -> Q [Dec] Source #

Defines an instance of the given class for MockT m, delegating all of its methods to mockMethod to be handled by HMock.

This may only be used if all members of the class are mockable methods. If the class contains some unmockable methods, associated types, or other members, you will need to define this instance yourself, delegating the mockable methods as follows:

instance MyClass (MockT m) where
  myMethod x y = mockMethod (MyMethod x y)
  ...

deriveTypeForMockT :: Q Type -> Q [Dec] Source #

Defines an instance of the given constraint type for MockT m, delegating all of its methods to mockMethod to be handled by HMock. The type should be a class applied to zero or more type arguments.

See deriveForMockT for restrictions on the use of this splice.

deriveForMockTWithOptions :: MockableOptions -> Name -> Q [Dec] Source #

Defines an instance of the given class for MockT m, delegating all of its methods to mockMethod to be handled by HMock. This is like deriveForMockT, but with the ability to specify custom options.

See deriveForMockT for restrictions on the use of this splice.

deriveTypeForMockTWithOptions :: MockableOptions -> Q Type -> Q [Dec] Source #

Defines an instance of the given constraint type for MockT m, delegating all of its methods to mockMethod to be handled by HMock. The type should be a class applied to zero or more type arguments. This is like deriveTypeForMockT, but with the ability to specify custom options.

See deriveForMockT for restrictions on the use of this splice.