diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2017-07-28 11:28:48 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2017-07-28 11:28:48 -0400 |
commit | b2225a374f24f1ee1a881bfd5d3c1f7b57447e47 (patch) | |
tree | 7324b2e0af30247b2f7cbaa7b0cfffd31035dbe6 /test/lisp/emacs-lisp/cl-generic-tests.el | |
parent | dc9c6a071c0c12be2bd490f85107486bca44623e (diff) | |
download | emacs-b2225a374f24f1ee1a881bfd5d3c1f7b57447e47.tar.gz |
* lisp/subr.el (method-files): Move function to cl-generic.el
* lisp/emacs-lisp/cl-generic.el (cl-generic-p): New function.
(cl--generic-method-files): New function, moved from subr.el.
* lisp/emacs-lisp/edebug.el (edebug-instrument-function): Use them.
* test/lisp/emacs-lisp/cl-generic-tests.el:
* test/lisp/subr-tests.el: Move and adjust method-files tests accordingly.
Diffstat (limited to 'test/lisp/emacs-lisp/cl-generic-tests.el')
-rw-r--r-- | test/lisp/emacs-lisp/cl-generic-tests.el | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/cl-generic-tests.el b/test/lisp/emacs-lisp/cl-generic-tests.el index 0768e31f7e6..31f65413c88 100644 --- a/test/lisp/emacs-lisp/cl-generic-tests.el +++ b/test/lisp/emacs-lisp/cl-generic-tests.el @@ -219,5 +219,29 @@ (should (equal (cl--generic-1 '(5) nil) '("cinq" (5)))) (should (equal (cl--generic-1 '(6) nil) '("six" a)))) +(cl-defgeneric cl-generic-tests--generic (x)) +(cl-defmethod cl-generic-tests--generic ((x string)) + (message "%s is a string" x)) +(cl-defmethod cl-generic-tests--generic ((x integer)) + (message "%s is a number" x)) +(cl-defgeneric cl-generic-tests--generic-without-methods (x y)) +(defvar cl-generic-tests--this-file + (file-truename (or load-file-name buffer-file-name))) + +(ert-deftest cl-generic-tests--method-files--finds-methods () + "`method-files' returns a list of files and methods for a generic function." + (let ((retval (cl--generic-method-files 'cl-generic-tests--generic))) + (should (equal (length retval) 2)) + (mapc (lambda (x) + (should (equal (car x) cl-generic-tests--this-file)) + (should (equal (cadr x) 'cl-generic-tests--generic))) + retval) + (should-not (equal (nth 0 retval) (nth 1 retval))))) + +(ert-deftest cl-generic-tests--method-files--nonexistent-methods () + "`method-files' returns nil if asked to find a method which doesn't exist." + (should-not (cl--generic-method-files 'cl-generic-tests--undefined-generic)) + (should-not (cl--generic-method-files 'cl-generic-tests--generic-without-methods))) + (provide 'cl-generic-tests) ;;; cl-generic-tests.el ends here |