package mock

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module MockSource

Sourcetype ('args, 'ret) t

A mock is something that can be used in place of function.

('args, 'ret) t is similar to 'args -> 'ret except that:

  • its return value (or effect) can be configured
  • it is possible to determine whether it has been called
Sourceval make : name:string -> ('args, 'ret) t

Build an unconfigured mock. Calling an unconfigured mock will raise an exception that contains the name of the mock.

Sourceval name : ('args, 'ret) t -> string

Retrieve the name of a mock.

Sourcetype 'a side_effect

What a mock can evaluate to.

Sourceval not_configured : 'a side_effect

Evaluation is not possible. call will raise Mock_non_configured.

Sourceval return : 'a -> 'a side_effect

Return a value.

Sourceval raise : exn -> 'a side_effect

Raise an exception.

Sourceval configure : ('args, 'ret) t -> 'ret side_effect -> unit

Define what a mock should return.

Sourceval call : ('args, 'ret) t -> 'args -> 'ret

Call the mock:

  • record its arguments
  • perform its side effects
Sourceexception Mock_not_configured of string

call will raise this exception if the mock has not been configured.

Sourceval recorded_calls : ('args, 'ret) t -> 'args list

Return the list of arguments this mock has received. The list is in the same order as the calls.

OCaml

Innovation. Community. Security.