diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/subr-tests.el | 24 |
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 |