From 244c658b3c7dc68c98f347657832258a2493ffb7 Mon Sep 17 00:00:00 2001 From: Olof-Joachim Frahm Date: Sat, 31 Jan 2015 23:31:14 +0000 Subject: [PATCH] Better invocation recording. --- src/mock.lisp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/mock.lisp b/src/mock.lisp index fab5f73..f1d38cb 100644 --- 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*))) +(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* - (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 -- 1.7.10.4