diff options
author | Philipp Stephani <phst@google.com> | 2020-08-02 18:05:36 +0200 |
---|---|---|
committer | Philipp Stephani <phst@google.com> | 2020-08-02 18:05:36 +0200 |
commit | 3e0c3479b24e1978d30bbcc00faac7bdd6bdd170 (patch) | |
tree | 6c986cb3485d84bf9eb638d5b5295c6b5a0ce8c0 /test/lisp/emacs-lisp/cl-generic-tests.el | |
parent | 0a65e060207def5d31fb7d96b8d3bb1441fd13c9 (diff) | |
download | emacs-3e0c3479b24e1978d30bbcc00faac7bdd6bdd170.tar.gz |
Add a workaround for Bug#42672
* lisp/emacs-lisp/cl-generic.el (cl-defgeneric): Work around Bug#42672
by uniquifying inline method names.
* test/lisp/emacs-lisp/cl-generic-tests.el
(cl-defgeneric/edebug/method): New regression test.
Diffstat (limited to 'test/lisp/emacs-lisp/cl-generic-tests.el')
-rw-r--r-- | test/lisp/emacs-lisp/cl-generic-tests.el | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/cl-generic-tests.el b/test/lisp/emacs-lisp/cl-generic-tests.el index 51c9884ddc8..fc39e349523 100644 --- a/test/lisp/emacs-lisp/cl-generic-tests.el +++ b/test/lisp/emacs-lisp/cl-generic-tests.el @@ -24,6 +24,7 @@ ;;; Code: (require 'cl-generic) +(require 'edebug) ;; Don't indirectly require `cl-lib' at run-time. (eval-when-compile (require 'ert)) @@ -249,5 +250,40 @@ (should-not (cl--generic-method-files 'cl-generic-tests--undefined-generic)) (should-not (cl--generic-method-files 'cl-generic-tests--generic-without-methods))) +(ert-deftest cl-defgeneric/edebug/method () + "Check that `:method' forms in `cl-defgeneric' create unique +Edebug symbols (Bug#42672)." + (with-temp-buffer + (dolist (form '((cl-defgeneric cl-defgeneric/edebug/method/1 (_) + (:method ((_ number)) 1) + (:method ((_ string)) 2)) + (cl-defgeneric cl-defgeneric/edebug/method/2 (_) + (:method ((_ number)) 3)))) + (print form (current-buffer))) + (let* ((edebug-all-defs t) + (edebug-initial-mode 'Go-nonstop) + (instrumented-names ()) + (edebug-new-definition-function + (lambda (name) + (when (memq name instrumented-names) + (error "Duplicate definition of `%s'" name)) + (push name instrumented-names) + (edebug-new-definition name))) + ;; Make generated symbols reproducible. + (gensym-counter 10000)) + (eval-buffer) + (should (equal (reverse instrumented-names) + ;; The generic function definitions come after + ;; the method definitions because their body ends + ;; later. + ;; FIXME: We'd rather have names such as + ;; `cl-defgeneric/edebug/method/1 ((_ number))', + ;; but that requires further changes to Edebug. + (list (intern "cl-generic-:method@10000 ((_ number))") + (intern "cl-generic-:method@10001 ((_ string))") + 'cl-defgeneric/edebug/method/1 + (intern "cl-generic-:method@10002 ((_ number))") + 'cl-defgeneric/edebug/method/2)))))) + (provide 'cl-generic-tests) ;;; cl-generic-tests.el ends here |