diff options
author | Philipp Stephani <phst@google.com> | 2022-09-13 17:11:53 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2022-09-13 17:11:53 +0200 |
commit | 6d8f5161ead689b7a2e44a7de0a695f0ab4c833b (patch) | |
tree | 006981ac2baf4bf7cc934fd3538a8629c1e8e8e3 /test/lisp/emacs-lisp/cl-macs-tests.el | |
parent | 07ee1be052a45d8e6f671d0851f11c545dd9511a (diff) | |
download | emacs-6d8f5161ead689b7a2e44a7de0a695f0ab4c833b.tar.gz emacs-6d8f5161ead689b7a2e44a7de0a695f0ab4c833b.tar.bz2 emacs-6d8f5161ead689b7a2e44a7de0a695f0ab4c833b.zip |
Signal an error if a fallback cl-case is misplaced
* lisp/emacs-lisp/cl-macs.el (cl-case): Warn if the user passes a nil
key list (which would never match). Warn about quoted symbols that
should probably be unquoted.
* test/lisp/emacs-lisp/cl-macs-tests.el (cl-case-warning): New unit
test (bug#51368).
Diffstat (limited to 'test/lisp/emacs-lisp/cl-macs-tests.el')
-rw-r--r-- | test/lisp/emacs-lisp/cl-macs-tests.el | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/cl-macs-tests.el b/test/lisp/emacs-lisp/cl-macs-tests.el index 68898720d9c..77817abd85c 100644 --- a/test/lisp/emacs-lisp/cl-macs-tests.el +++ b/test/lisp/emacs-lisp/cl-macs-tests.el @@ -747,4 +747,15 @@ collection clause." ;; Just make sure the forms can be instrumented. (eval-buffer)))) +(ert-deftest cl-case-error () + "Test that `cl-case' and `cl-ecase' signal an error if a t or +`otherwise' key is misplaced." + (dolist (form '((cl-case val (t 1) (123 2)) + (cl-ecase val (t 1) (123 2)) + (cl-ecase val (123 2) (t 1)))) + (ert-info ((prin1-to-string form) :prefix "Form: ") + (let ((error (should-error (macroexpand form)))) + (should (equal (cdr error) + '("Misplaced t or `otherwise' clause"))))))) + ;;; cl-macs-tests.el ends here |