The cl-mock Reference Manual

This is the cl-mock Reference Manual, version 1.1.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Wed May 15 04:15:21 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 cl-mock

Mocking library

Author

Olof-Joachim Frahm <>

License

AGPL-3+

Long Description

Mocking library to test plain functions (extended version).

Version

1.1.0

Dependencies
Source

cl-mock.asd.

Child Component

src (module).


2.2 cl-mock-basic

Mocking library

Author

Olof-Joachim Frahm <>

License

AGPL-3+

Long Description

Mocking library to test plain functions.

Version

1.1.0

Dependencies
  • closer-mop (system).
  • alexandria (system).
  • bordeaux-threads (system).
Source

cl-mock-basic.asd.

Child Components

3 Modules

Modules are listed depth-first from the system components tree.


3.1 cl-mock/src

Source

cl-mock.asd.

Parent Component

cl-mock (system).

Child Component

facade.lisp (file).


3.2 cl-mock-basic/src

Dependency

readme.md (file).

Source

cl-mock-basic.asd.

Parent Component

cl-mock-basic (system).

Child Components

4 Files

Files are sorted by type and then listed depth-first from the systems components trees.


4.1 Lisp


4.1.1 cl-mock/cl-mock.asd

Source

cl-mock.asd.

Parent Component

cl-mock (system).

ASDF Systems

cl-mock.


4.1.2 cl-mock-basic/cl-mock-basic.asd

Source

cl-mock-basic.asd.

Parent Component

cl-mock-basic (system).

ASDF Systems

cl-mock-basic.


4.1.3 cl-mock/src/facade.lisp

Source

cl-mock.asd.

Parent Component

src (module).

Public Interface

answer (macro).

Internals

true (function).


4.1.4 cl-mock-basic/src/package.lisp

Source

cl-mock-basic.asd.

Parent Component

src (module).

Packages

cl-mock.


4.1.5 cl-mock-basic/src/functions.lisp

Source

cl-mock-basic.asd.

Parent Component

src (module).

Public Interface

4.1.6 cl-mock-basic/src/mock.lisp

Source

cl-mock-basic.asd.

Parent Component

src (module).

Public Interface
Internals

4.2 Static


4.2.1 cl-mock-basic/README.md

Source

cl-mock-basic.asd.

Parent Component

cl-mock-basic (system).


5 Packages

Packages are listed by definition order.


5.1 cl-mock

Source

package.lisp.

Use List
  • alexandria.
  • closer-common-lisp.
Public Interface
Internals

6 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


6.1 Public Interface


6.1.1 Special variables

Special Variable: *arguments*
Package

cl-mock.

Source

mock.lisp.

Special Variable: *previous*
Package

cl-mock.

Source

mock.lisp.


6.1.2 Macros

Macro: answer (call &body forms)
Package

cl-mock.

Source

facade.lisp.

Macro: dflet ((&rest definitions) &body body)

Like FLET, but dynamically sets the FDEFINITIONS during the duration of the BODY.

Package

cl-mock.

Source

functions.lisp.

Macro: progf (functions values &body body)

Like PROGV, but for FUNCTIONS.

Package

cl-mock.

Source

functions.lisp.

Macro: with-mocks ((&key recordp) &body body)

Execute BODY in a new mocking context. Invocations will be recorded if RECORDP is set (default true).

Package

cl-mock.

Source

mock.lisp.


6.1.3 Ordinary functions

Function: call-previous (&rest args)

Invokes the previous binding either with the current arguments or with the given ones. Use *PREVIOUS*/*ARGUMENTS* directly in edge cases.

Package

cl-mock.

Source

mock.lisp.

Function: call-with-function-bindings (functions values function &optional previous)

Calls FUNCTION while temporarily binding all FUNCTIONS with the given names to VALUES. See PROGF and PROGV. If PREVIOUS is set, it has to be the list of original values for each function.

Package

cl-mock.

Source

functions.lisp.

Function: call-with-mocks (function &key recordp)

Call FUNCTION with a new mocking context. Invocations will be recorded if RECORDP is set (default true).

Package

cl-mock.

Source

mock.lisp.

Function: if-called (name function &key at-start)

Registers a new binding, which should return true if it handled the invocation. If AT-START is set, the binding is put at the start of the bindings list instead. Calls REGISTER-MOCK automatically.

Package

cl-mock.

Source

mock.lisp.

Function: invocations (&optional name)
Package

cl-mock.

Source

mock.lisp.

Function: maybe-fdefinition (name)

If NAME is FBOUNDP, return its FDEFINITION, else NIL.

Package

cl-mock.

Source

functions.lisp.

Function: register-mock (name)

Registers a mocked function under NAME. The mocked function will return no values. See IF-CALLED to add some behaviour to it.

Package

cl-mock.

Source

mock.lisp.

Function: set-fdefinition (name value)

FUNCALLABLE expansion of (SETF (FDEFINITION NAME) VALUE).

Package

cl-mock.

Source

functions.lisp.

Function: set-or-unbind-fdefinition (name value)

If VALUE is true, set the FDEFINITION of NAME to it, else FMAKUNBOUND it completely.

Package

cl-mock.

Source

functions.lisp.

Function: unhandled ()
Package

cl-mock.

Source

mock.lisp.


6.2 Internals


6.2.1 Special variables

Special Variable: *invocations*
Package

cl-mock.

Source

mock.lisp.

Special Variable: *invocations-lock*
Package

cl-mock.

Source

mock.lisp.

Special Variable: *mock-bindings*
Package

cl-mock.

Source

mock.lisp.

Special Variable: *recordp*
Package

cl-mock.

Source

mock.lisp.


6.2.2 Ordinary functions

Function: find-and-invoke-mock (binding *arguments*)

Looks for a compatible mock (i.e. calls the TEST until one returns true) and executes it. If no mock was found, no values are returned instead.

Package

cl-mock.

Source

mock.lisp.

Function: record-invocation (record)
Package

cl-mock.

Source

mock.lisp.

Function: true (&rest arguments)
Package

cl-mock.

Source

facade.lisp.


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   A   C   D   F   I   M   P   R   S   T   U   W  
Index Entry  Section

A
answer: Public macros

C
call-previous: Public ordinary functions
call-with-function-bindings: Public ordinary functions
call-with-mocks: Public ordinary functions

D
dflet: Public macros

F
find-and-invoke-mock: Private ordinary functions
Function, call-previous: Public ordinary functions
Function, call-with-function-bindings: Public ordinary functions
Function, call-with-mocks: Public ordinary functions
Function, find-and-invoke-mock: Private ordinary functions
Function, if-called: Public ordinary functions
Function, invocations: Public ordinary functions
Function, maybe-fdefinition: Public ordinary functions
Function, record-invocation: Private ordinary functions
Function, register-mock: Public ordinary functions
Function, set-fdefinition: Public ordinary functions
Function, set-or-unbind-fdefinition: Public ordinary functions
Function, true: Private ordinary functions
Function, unhandled: Public ordinary functions

I
if-called: Public ordinary functions
invocations: Public ordinary functions

M
Macro, answer: Public macros
Macro, dflet: Public macros
Macro, progf: Public macros
Macro, with-mocks: Public macros
maybe-fdefinition: Public ordinary functions

P
progf: Public macros

R
record-invocation: Private ordinary functions
register-mock: Public ordinary functions

S
set-fdefinition: Public ordinary functions
set-or-unbind-fdefinition: Public ordinary functions

T
true: Private ordinary functions

U
unhandled: Public ordinary functions

W
with-mocks: Public macros