summaryrefslogtreecommitdiff
path: root/test/lisp/emacs-lisp/macroexp-tests.el
diff options
context:
space:
mode:
authorYuuki Harano <masm+github@masm11.me>2021-03-08 21:20:54 +0900
committerYuuki Harano <masm+github@masm11.me>2021-03-08 21:20:54 +0900
commit4dda6db3abf4a67455a007d28e14d62a9909f665 (patch)
tree88d4e316e81f5bdd8b6801ff89ea68cd164e4055 /test/lisp/emacs-lisp/macroexp-tests.el
parent565995d408ca65ec9f981f175cca29d2164a5fd0 (diff)
parent432c1aaa80ce109250a93f50858a03ce3d01ca34 (diff)
downloademacs-4dda6db3abf4a67455a007d28e14d62a9909f665.tar.gz
emacs-4dda6db3abf4a67455a007d28e14d62a9909f665.tar.bz2
emacs-4dda6db3abf4a67455a007d28e14d62a9909f665.zip
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs into feature/pgtk
Diffstat (limited to 'test/lisp/emacs-lisp/macroexp-tests.el')
-rw-r--r--test/lisp/emacs-lisp/macroexp-tests.el38
1 files changed, 37 insertions, 1 deletions
diff --git a/test/lisp/emacs-lisp/macroexp-tests.el b/test/lisp/emacs-lisp/macroexp-tests.el
index 1124e3b8d91..89d3882d1da 100644
--- a/test/lisp/emacs-lisp/macroexp-tests.el
+++ b/test/lisp/emacs-lisp/macroexp-tests.el
@@ -1,6 +1,6 @@
;;; macroexp-tests.el --- Tests for macroexp.el -*- lexical-binding: t; -*-
-;; Copyright (C) 2021 Stefan Monnier
+;; Copyright (C) 2021 Free Software Foundation, Inc.
;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
;; Keywords:
@@ -32,5 +32,41 @@
(should (equal (macroexp--fgrep '((x) (y)) '#2=([r] ((a x)) a b c d . #2#))
'((x)))))
+(defconst macroexp--tests-filename (macroexp-file-name))
+
+(defmacro macroexp--test-get-file-name () (macroexp-file-name))
+
+(ert-deftest macroexp--tests-file-name ()
+ (should (string-match
+ "\\`macroexp-tests.elc?\\'"
+ (file-name-nondirectory macroexp--tests-filename)))
+ (let ((rsrc-dir (expand-file-name
+ "macroexp-resources"
+ (file-name-directory macroexp--tests-filename))))
+ (with-current-buffer
+ (find-file-noselect (expand-file-name "m1.el" rsrc-dir))
+ (defvar macroexp--m1-tests-filename)
+ (declare-function macroexp--m1-tests-file-name "m1" ())
+ ;; `macroexp-file-name' should work with `eval-buffer'.
+ (eval-buffer)
+ (should (equal "m1.el"
+ (file-name-nondirectory macroexp--m1-tests-filename)))
+ (should (equal "m1.el"
+ (file-name-nondirectory (macroexp--m1-tests-file-name))))
+ (search-forward "macroexp--m1-tests-filename")
+ (makunbound 'macroexp--m1-tests-filename)
+ ;; `macroexp-file-name' should also work with `eval-defun'.
+ (eval-defun nil)
+ (should (equal "m1.el"
+ (file-name-nondirectory macroexp--m1-tests-filename))))
+
+ ;; Test the case where we load a file which byte-compiles another.
+ (defvar macroexp--m1-tests-comp-filename)
+ (makunbound 'macroexp--m1-tests-comp-filename)
+ (load (expand-file-name "m2.el" rsrc-dir))
+ (should (equal "m1.el"
+ (file-name-nondirectory macroexp--m1-tests-comp-filename)))))
+
+
(provide 'macroexp-tests)
;;; macroexp-tests.el ends here