1 -*- mode: markdown; coding: utf-8-unix; -*-
3 CL-MOCK - Mocking (generic) functions.
5 Copyright (C) 2013 Olof-Joachim Frahm
7 Release under a Simplified BSD license.
9 Working, but unfinished.
11 Should be portable thanks to [`CLOSER-MOP`][1].
13 Since it is pretty easy to just roll something like this on your own,
14 the main purpose is to develop a nice syntax (lispy, declarative) to
15 keep tests readable and maintainable.
17 Some parts may be used independently of the testing facilities,
18 e.g. dynamic `FLET` and method bindings with `PROGM` may be of general
24 Since behaviour isn't bound to classes, but to generic functions,
25 creating new classes on the fly isn't particularly interesting.
27 We provide the form `PROGM` to bind a number of methods during the
28 execution of its contained body:
32 > '((lambda (list) list))
37 > (defclass foo () ())
38 > (defgeneric baz (foo)
41 > (progm '((baz NIL (list)))
42 '((lambda (list) list))
43 (values (baz (make-instance 'foo)) (baz '(1 2 3))))
50 `DFLET` dynamically rebinds functions similar to `FLET`:
53 > (defun bar () (foo))
56 > (dflet ((foo () 23))
59 > (OR) => 42, if FOO was inlined
61 The caveat is that this might not work on certain optimization settings,
64 The underlying function `PROGF` may be used as well similarly to standard
67 > (progf '(foo) (list (lambda () 23))
70 > (OR) => 42, if FOO was inlined
72 [1]: http://common-lisp.net/project/closer/closer-mop.html