diff options
| author | Noam Postavsky | 2017-04-27 17:13:33 -0400 |
|---|---|---|
| committer | Marcin Borkowski | 2017-05-12 11:40:48 +0200 |
| commit | cb8fcbc3cbd8f6cf95bb858b72188d752672cf6b (patch) | |
| tree | c2c61375a210a41196fb3c1f8cb8f91f538c23da | |
| parent | 0397f85c6f9b0a5325f774e2a56e7cd85176e228 (diff) | |
| download | emacs-cb8fcbc3cbd8f6cf95bb858b72188d752672cf6b.tar.gz emacs-cb8fcbc3cbd8f6cf95bb858b72188d752672cf6b.zip | |
Fix elisp-tests-with-temp-buffer compilation
* test/lisp/emacs-lisp/lisp-tests.el (elisp-tests-with-temp-buffer):
Don't refer to the =!NAME= as "markers" since they produce variables
with just plain positions, not marker objects. Explicitly specify
that CONTENTS is evaluated at compile time. Don't re-evaluate
CONTENTS at runtime. Fix debug specification. Suppress warnings due
to BODY not using =!NAME= variables.
(elisp-test-point-position-regex): Rename from
`elisp-test-point-marker-regex'.
(mark-defun-test-buffer): Wrap in `eval-and-compile'.
| -rw-r--r-- | test/lisp/emacs-lisp/lisp-tests.el | 66 |
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. |
| 316 | BODY is the code to be executed within the temp buffer. Point is | 317 | BODY is the code to be executed within the temp buffer. Point is |
| 317 | always located at the beginning of buffer. Special markers of | 318 | always located at the beginning of buffer. CONTENTS is an |
| 318 | the form =!NAME= in CONTENTS are removed, and a for each one | 319 | expression that must evaluate to a string at compile time. Words |
| 319 | a variable called NAME is bound to the position of such | 320 | of the form =!NAME= in CONTENTS are removed, and a for each one a |
| 320 | a marker." | 321 | variable called NAME is bound to the position of the word's |
| 321 | (declare (indent 1) (debug t)) | 322 | start." |
| 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 |