aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/lisp/emacs-lisp/lisp-tests.el66
1 files changed, 33 insertions, 33 deletions
diff --git a/test/lisp/emacs-lisp/lisp-tests.el b/test/lisp/emacs-lisp/lisp-tests.el
index 2119758bb77..ddbf378683b 100644
--- a/test/lisp/emacs-lisp/lisp-tests.el
+++ b/test/lisp/emacs-lisp/lisp-tests.el
@@ -306,46 +306,46 @@
306 306
307;;; Helpers 307;;; Helpers
308 308
309(defvar elisp-test-point-marker-regex "=!\\([a-zA-Z0-9-]+\\)=" 309(eval-and-compile
310 "A regexp matching placeholders for point position for 310 (defvar elisp-test-point-position-regex "=!\\([a-zA-Z0-9-]+\\)="
311`elisp-tests-with-temp-buffer'.") 311 "A regexp matching placeholders for point position for
312`elisp-tests-with-temp-buffer'."))
312 313
313;; Copied and heavily modified from `python-tests-with-temp-buffer' 314;; Copied and heavily modified from `python-tests-with-temp-buffer'
314(defmacro elisp-tests-with-temp-buffer (contents &rest body) 315(defmacro elisp-tests-with-temp-buffer (contents &rest body)
315 "Create an `emacs-lisp-mode' enabled temp buffer with CONTENTS. 316 "Create an `emacs-lisp-mode' enabled temp buffer with CONTENTS.
316BODY is the code to be executed within the temp buffer. Point is 317BODY is the code to be executed within the temp buffer. Point is
317always located at the beginning of buffer. Special markers of 318always located at the beginning of buffer. CONTENTS is an
318the form =!NAME= in CONTENTS are removed, and a for each one 319expression that must evaluate to a string at compile time. Words
319a variable called NAME is bound to the position of such 320of the form =!NAME= in CONTENTS are removed, and a for each one a
320a marker." 321variable called NAME is bound to the position of the word's
321 (declare (indent 1) (debug t)) 322start."
322 `(with-temp-buffer 323 (declare (indent 1) (debug (def-form body)))
323 (emacs-lisp-mode) 324 (let* ((var-pos nil)
324 (insert ,contents) 325 (text (with-temp-buffer
325 (goto-char (point-min)) 326 (insert (eval contents))
326 (while (re-search-forward elisp-test-point-marker-regex nil t) 327 (goto-char (point-min))
327 (delete-region (match-beginning 0) 328 (while (re-search-forward elisp-test-point-position-regex nil t)
328 (match-end 0))) 329 (push (list (intern (match-string-no-properties 1))
329 (goto-char (point-min)) 330 (match-beginning 0))
330 ,(let (marker-list) 331 var-pos)
331 (with-temp-buffer 332 (delete-region (match-beginning 0)
332 (insert (cond ((symbolp contents) 333 (match-end 0)))
333 (symbol-value contents)) 334 (buffer-string))))
334 (t contents))) 335 `(with-temp-buffer
335 (goto-char (point-min)) 336 (emacs-lisp-mode)
336 (while (re-search-forward elisp-test-point-marker-regex nil t) 337 (insert ,text)
337 (push (list (intern (match-string-no-properties 1)) 338 (goto-char (point-min))
338 (match-beginning 0)) 339 (let ,var-pos
339 marker-list) 340 ;; Let the =!POSITION= variables be ignorable.
340 (delete-region (match-beginning 0) 341 ,@(mapcar (lambda (v-p) `(ignore ,(car v-p))) var-pos)
341 (match-end 0)))) 342 ,@body))))
342 `(let ,marker-list
343 ,@body))))
344 343
345;;; mark-defun 344;;; mark-defun
346 345
347(defvar mark-defun-test-buffer 346(eval-and-compile
348 ";; Comment header 347 (defvar mark-defun-test-buffer
348 ";; Comment header
349=!before-1= 349=!before-1=
350\(defun func-1 (arg) 350\(defun func-1 (arg)
351 =!inside-1=\"docstring\" 351 =!inside-1=\"docstring\"
@@ -365,7 +365,7 @@ a marker."
365=!after-4= 365=!after-4=
366;; end 366;; end
367" 367"
368 "Test buffer for `mark-defun'.") 368 "Test buffer for `mark-defun'."))
369 369
370(ert-deftest mark-defun-no-arg-region-inactive () 370(ert-deftest mark-defun-no-arg-region-inactive ()
371 "Test `mark-defun' with no prefix argument and inactive 371 "Test `mark-defun' with no prefix argument and inactive