Simplify by using ALEXANDRIA.
authorOlof-Joachim Frahm <olof@macrolet.net>
Mon, 10 Jun 2013 21:40:15 +0000 (23:40 +0200)
committerOlof-Joachim Frahm <olof@macrolet.net>
Mon, 10 Jun 2013 21:40:15 +0000 (23:40 +0200)
cl-mock.asd
src/methods.lisp
src/package.lisp

index 54861d6..c6aa5f6 100644 (file)
@@ -7,7 +7,7 @@
   :description "Mocking (generic) functions."
   :author "Olof-Joachim Frahm <olof@macrolet.net>"
   :license "Simplified BSD License"
-  :depends-on (#:closer-mop)
+  :depends-on (#:closer-mop #:alexandria)
   :in-order-to ((asdf:test-op (asdf:load-op #:cl-mock-tests)))
   :perform (asdf:test-op :after (op c)
              (funcall (find-symbol (symbol-name '#:run!) '#:fiveam)
index 7cdbd98..ec9bba7 100644 (file)
 (defmacro progm* (methods values &body body)
   `(call-with-method-bindings* ,methods ,values (lambda () ,@body)))
 
+(defun classify (specializer)
+  (if (classp specializer)
+      specializer
+      (find-class specializer)))
+
 (defun call-with-method-bindings (methods values function
                                   &optional previous)
   (let ((methods
           (mapcar (lambda (method)
                     (destructuring-bind (generic-function qualifiers specializers) method
                       (list
-                       (if (functionp generic-function)
-                           generic-function
-                           (fdefinition generic-function))
+                       (ensure-function generic-function)
                        qualifiers
-                       (mapcar (lambda (specializer)
-                                 (if (classp specializer)
-                                     specializer
-                                     (find-class specializer)))
-                               specializers))))
+                       (mapcar #'classify specializers))))
                   methods)))
     (call-with-method-bindings* methods values function (or previous (find-methods methods)))))
 
index 8e8ef92..a41f543 100644 (file)
@@ -3,7 +3,7 @@
 (in-package #:cl-user)
 
 (defpackage #:cl-mock
-  (:use #:closer-common-lisp)
+  (:use #:closer-common-lisp #:alexandria)
   (:export ;;; regular functions
            #:dflet