summaryrefslogtreecommitdiff
path: root/test/lisp/emacs-lisp/macroexp-tests.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2023-07-19 11:29:32 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2023-07-21 11:48:42 -0400
commitca4bc9baf9d2c861ad776da07e56381da8e3722a (patch)
tree17550fdaa0e733f33223b511cc456e30561629ca /test/lisp/emacs-lisp/macroexp-tests.el
parentb9a910a701a792825462a75332a9aec6824fe874 (diff)
downloademacs-ca4bc9baf9d2c861ad776da07e56381da8e3722a.tar.gz
emacs-ca4bc9baf9d2c861ad776da07e56381da8e3722a.tar.bz2
emacs-ca4bc9baf9d2c861ad776da07e56381da8e3722a.zip
macroexp.el: Fix missing warning for intermediate expansions
When a macro expanded to a call to an obsolete macro, we failed to emit a warning for that use of the obsolete macro. * lisp/emacs-lisp/macroexp.el (macroexp-macroexpand): Use `macroexpand-1` to check obsolecence of intermediate expansions. * test/lisp/emacs-lisp/macroexp-tests.el (macroexp--test-obsolete-macro): New test.
Diffstat (limited to 'test/lisp/emacs-lisp/macroexp-tests.el')
-rw-r--r--test/lisp/emacs-lisp/macroexp-tests.el16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/macroexp-tests.el b/test/lisp/emacs-lisp/macroexp-tests.el
index 7bb38fe58f7..d0efbfd28c1 100644
--- a/test/lisp/emacs-lisp/macroexp-tests.el
+++ b/test/lisp/emacs-lisp/macroexp-tests.el
@@ -124,4 +124,20 @@
(dyn dyn dyn dyn)
(dyn dyn dyn lex))))))
+(defmacro macroexp--test-macro1 ()
+ (declare (obsolete "new-replacement" nil))
+ 1)
+
+(defmacro macroexp--test-macro2 ()
+ '(macroexp--test-macro1))
+
+(ert-deftest macroexp--test-obsolete-macro ()
+ (should
+ (let ((res
+ (cl-letf (((symbol-function 'message) #'user-error))
+ (condition-case err
+ (macroexpand-all '(macroexp--test-macro2))
+ (user-error (error-message-string err))))))
+ (should (and (stringp res) (string-match "new-replacement" res))))))
+
;;; macroexp-tests.el ends here