projects
/
cl-mock.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b7ffdb1
)
Better invocation recording.
master
author
Olof-Joachim Frahm
<olof@macrolet.net>
Sat, 31 Jan 2015 23:31:14 +0000
(23:31 +0000)
committer
Olof-Joachim Frahm
<olof@macrolet.net>
Sat, 31 Jan 2015 23:32:31 +0000
(23:32 +0000)
src/mock.lisp
patch
|
blob
|
history
diff --git
a/src/mock.lisp
b/src/mock.lisp
index
fab5f73
..
f1d38cb
100644
(file)
--- a/
src/mock.lisp
+++ b/
src/mock.lisp
@@
-22,16
+22,17
@@
the given ones. Use *PREVIOUS*/*ARGUMENTS* directly in edge cases."
(apply *previous* (or args *arguments*)))
the given ones. Use *PREVIOUS*/*ARGUMENTS* directly in edge cases."
(apply *previous* (or args *arguments*)))
+(defun record-invocation (record &aux (record (list record)))
+ (setf (cdr *invocations*)
+ (if (null (car *invocations*))
+ (setf (car *invocations*) record)
+ (setf (cddr *invocations*) record))))
+
(defun 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."
(when *recordp*
(defun 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."
(when *recordp*
- (let ((record (list (cons (car binding) *arguments*))))
- (if (null (car *invocations*))
- (setf (cdr *invocations*)
- (setf (car *invocations*) record))
- (setf (cdr *invocations*)
- (setf (cddr *invocations*) record)))))
+ (record-invocation (cons (car binding) *arguments*)))
(dolist (case (cdddr binding) (values))
(let ((*previous* (cadr binding)))
(catch 'unhandled
(dolist (case (cdddr binding) (values))
(let ((*previous* (cadr binding)))
(catch 'unhandled