aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorGemini Lasswell2017-05-13 11:35:49 -0700
committerDmitry Gutov2017-05-14 23:32:27 +0300
commite6f64df9c2b443d3385c2c25c29ccd5283d37e3f (patch)
tree487563d05e1133b4dc7147ed48b87c69e6fd4ff7 /test
parent10037e4be2358597125a05db93f6fee551131d83 (diff)
downloademacs-e6f64df9c2b443d3385c2c25c29ccd5283d37e3f.tar.gz
emacs-e6f64df9c2b443d3385c2c25c29ccd5283d37e3f.zip
Make edebug-step-in work on generic methods (Bug#22294)
* lisp/emacs-lisp/edebug.el (edebug-match-cl-generic-method-args): New function to implement the edebug-form-spec property of the symbol cl-generic-method-args. (edebug-instrument-function): If the function is a generic function, find and instrument all of its methods. Return a list instead of a single symbol. (edebug-instrument-callee): Now returns a list. Update docstring. (edebug-step-in): Handle the list returned by edebug-instrument-callee. * lisp/emacs-lisp/cl-generic.el (cl-defmethod): Use name and cl-generic-method-args in its Edebug spec. * lisp/emacs-lisp/eieio-compat.el (defmethod): Use name and cl-generic-method-args in its Edebug spec. * lisp/subr.el (method-files): New function. * test/lisp/subr-tests.el (subr-tests--method-files--finds-methods) (subr-tests--method-files--nonexistent-methods): New tests.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/subr-tests.el24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el
index 0d243cc5d8c..8fa258d12ed 100644
--- a/test/lisp/subr-tests.el
+++ b/test/lisp/subr-tests.el
@@ -291,5 +291,29 @@ cf. Bug#25477."
291 (should-error (eval '(dolist "foo") t) 291 (should-error (eval '(dolist "foo") t)
292 :type 'wrong-type-argument)) 292 :type 'wrong-type-argument))
293 293
294(require 'cl-generic)
295(cl-defgeneric subr-tests--generic (x))
296(cl-defmethod subr-tests--generic ((x string))
297 (message "%s is a string" x))
298(cl-defmethod subr-tests--generic ((x integer))
299 (message "%s is a number" x))
300(cl-defgeneric subr-tests--generic-without-methods (x y))
301(defvar subr-tests--this-file (or load-file-name buffer-file-name))
302
303(ert-deftest subr-tests--method-files--finds-methods ()
304 "`method-files' returns a list of files and methods for a generic function."
305 (let ((retval (method-files 'subr-tests--generic)))
306 (should (equal (length retval) 2))
307 (mapc (lambda (x)
308 (should (equal (car x) subr-tests--this-file))
309 (should (equal (cadr x) 'subr-tests--generic)))
310 retval)
311 (should-not (equal (nth 0 retval) (nth 1 retval)))))
312
313(ert-deftest subr-tests--method-files--nonexistent-methods ()
314 "`method-files' returns nil if asked to find a method which doesn't exist."
315 (should-not (method-files 'subr-tests--undefined-generic))
316 (should-not (method-files 'subr-tests--generic-without-methods)))
317
294(provide 'subr-tests) 318(provide 'subr-tests)
295;;; subr-tests.el ends here 319;;; subr-tests.el ends here