diff options
| author | Lars Ingebrigtsen | 2022-09-14 02:30:54 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2022-09-14 02:30:54 +0200 |
| commit | 10e9ec6da457ed32236ed9c70aa6cc3fdf9ae7ea (patch) | |
| tree | fecbaf2e95aa24712949629b2fae685ed10508cb /test | |
| parent | c4235eb26db27df63982083455f355ac9b46d70f (diff) | |
| download | emacs-10e9ec6da457ed32236ed9c70aa6cc3fdf9ae7ea.tar.gz emacs-10e9ec6da457ed32236ed9c70aa6cc3fdf9ae7ea.zip | |
Fix recently-added cl-macs tests
* test/lisp/emacs-lisp/cl-macs-tests.el (cl-case-error)
(cl-case-warning): Fix warning matches.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/emacs-lisp/cl-macs-tests.el | 66 |
1 files changed, 34 insertions, 32 deletions
diff --git a/test/lisp/emacs-lisp/cl-macs-tests.el b/test/lisp/emacs-lisp/cl-macs-tests.el index 427b8f46893..83928775f18 100644 --- a/test/lisp/emacs-lisp/cl-macs-tests.el +++ b/test/lisp/emacs-lisp/cl-macs-tests.el | |||
| @@ -752,42 +752,44 @@ collection clause." | |||
| 752 | (ert-deftest cl-case-error () | 752 | (ert-deftest cl-case-error () |
| 753 | "Test that `cl-case' and `cl-ecase' signal an error if a t or | 753 | "Test that `cl-case' and `cl-ecase' signal an error if a t or |
| 754 | `otherwise' key is misplaced." | 754 | `otherwise' key is misplaced." |
| 755 | (dolist (form '((cl-case val (t 1) (123 2)) | 755 | (let ((text-quoting-style 'grave)) |
| 756 | (cl-ecase val (t 1) (123 2)) | 756 | (dolist (form '((cl-case val (t 1) (123 2)) |
| 757 | (cl-ecase val (123 2) (t 1)))) | 757 | (cl-ecase val (t 1) (123 2)) |
| 758 | (ert-info ((prin1-to-string form) :prefix "Form: ") | 758 | (cl-ecase val (123 2) (t 1)))) |
| 759 | (let ((error (should-error (macroexpand form)))) | 759 | (ert-info ((prin1-to-string form) :prefix "Form: ") |
| 760 | (should (equal (cdr error) | 760 | (let ((error (should-error (macroexpand form)))) |
| 761 | '("Misplaced t or `otherwise' clause"))))))) | 761 | (should (equal (cdr error) |
| 762 | '("Misplaced t or `otherwise' clause")))))))) | ||
| 762 | 763 | ||
| 763 | (ert-deftest cl-case-warning () | 764 | (ert-deftest cl-case-warning () |
| 764 | "Test that `cl-case' and `cl-ecase' warn about suspicious | 765 | "Test that `cl-case' and `cl-ecase' warn about suspicious |
| 765 | constructs." | 766 | constructs." |
| 766 | (pcase-dolist (`(,case . ,message) | 767 | (let ((text-quoting-style 'grave)) |
| 767 | `((nil . "Case nil will never match") | 768 | (pcase-dolist (`(,case . ,message) |
| 768 | ('nil . ,(concat "Case 'nil will match `quote'. " | 769 | `((nil . "Case nil will never match") |
| 770 | ('nil . ,(concat "Case 'nil will match `quote'. " | ||
| 771 | "If that's intended, write " | ||
| 772 | "(nil quote) instead. " | ||
| 773 | "Otherwise, don't quote `nil'.")) | ||
| 774 | ('t . ,(concat "Case 't will match `quote'. " | ||
| 769 | "If that's intended, write " | 775 | "If that's intended, write " |
| 770 | "(nil quote) instead. " | 776 | "(t quote) instead. " |
| 771 | "Otherwise, don't quote `nil'.")) | 777 | "Otherwise, don't quote `t'.")) |
| 772 | ('t . ,(concat "Case 't will match `quote'. " | 778 | ('foo . ,(concat "Case 'foo will match `quote'. " |
| 773 | "If that's intended, write " | 779 | "If that's intended, write " |
| 774 | "(t quote) instead. " | 780 | "(foo quote) instead. " |
| 775 | "Otherwise, don't quote `t'.")) | 781 | "Otherwise, don't quote `foo'.")) |
| 776 | ('foo . ,(concat "Case 'foo will match `quote'. " | 782 | (#'foo . ,(concat "Case #'foo will match " |
| 777 | "If that's intended, write " | 783 | "`function'. If that's " |
| 778 | "(foo quote) instead. " | 784 | "intended, write (foo function) " |
| 779 | "Otherwise, don't quote `foo'.")) | 785 | "instead. Otherwise, don't " |
| 780 | (#'foo . ,(concat "Case #'foo will match " | 786 | "quote `foo'.")))) |
| 781 | "`function'. If that's " | 787 | (dolist (macro '(cl-case cl-ecase)) |
| 782 | "intended, write (foo function) " | 788 | (let ((form `(,macro val (,case 1)))) |
| 783 | "instead. Otherwise, don't " | 789 | (ert-info ((prin1-to-string form) :prefix "Form: ") |
| 784 | "quote `foo'.")))) | 790 | (ert-with-message-capture messages |
| 785 | (dolist (macro '(cl-case cl-ecase)) | 791 | (macroexpand form) |
| 786 | (let ((form `(,macro val (,case 1)))) | 792 | (should (equal messages |
| 787 | (ert-info ((prin1-to-string form) :prefix "Form: ") | 793 | (concat "Warning: " message "\n")))))))))) |
| 788 | (ert-with-message-capture messages | ||
| 789 | (macroexpand form) | ||
| 790 | (should (equal messages | ||
| 791 | (concat "Warning: " message "\n"))))))))) | ||
| 792 | 794 | ||
| 793 | ;;; cl-macs-tests.el ends here | 795 | ;;; cl-macs-tests.el ends here |