From: Olof-Joachim Frahm Date: Sat, 31 Jan 2015 23:31:14 +0000 (+0000) Subject: Better invocation recording. X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=244c658b3c7dc68c98f347657832258a2493ffb7;hp=b7ffdb1073541639cdaa738be073bc3e477d2ec3;p=cl-mock.git Better invocation recording. --- 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