diff options
| author | Philipp Stephani | 2015-06-30 22:38:35 +0200 |
|---|---|---|
| committer | Philipp Stephani | 2017-05-01 20:39:10 +0200 |
| commit | c2bbdc3316487e34eba1470dd059c0c290431e00 (patch) | |
| tree | bed5315e69d89c99c62be4a78e8f26d799643f70 /test/src | |
| parent | b72e36047c9a5d46b02e12252e0fc640b6839903 (diff) | |
| download | emacs-c2bbdc3316487e34eba1470dd059c0c290431e00.tar.gz emacs-c2bbdc3316487e34eba1470dd059c0c290431e00.zip | |
Warn about missing backslashes during load
* src/lread.c (load_warn_unescaped_character_literals, Fload, read1)
(syms_of_lread): Warn if unescaped character literals are
found (Bug#20152).
* lisp/emacs-lisp/bytecomp.el (byte-compile-from-buffer): Check for
unescaped character literals during byte compilation.
* test/src/lread-tests.el (lread-tests--unescaped-char-literals): New
unit test.
(lread-tests--with-temp-file, lread-tests--last-message): Helper
functions for unit test.
* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp-tests--unescaped-char-literals): New unit test.
* test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--with-temp-file):
Helper macro for unit test.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/lread-tests.el | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/src/lread-tests.el b/test/src/lread-tests.el index 27f967f045b..84342348d45 100644 --- a/test/src/lread-tests.el +++ b/test/src/lread-tests.el | |||
| @@ -116,4 +116,30 @@ | |||
| 116 | (should (equal '(#s(foo) #s(foo)) | 116 | (should (equal '(#s(foo) #s(foo)) |
| 117 | (read "(#1=#s(foo) #1#)")))) | 117 | (read "(#1=#s(foo) #1#)")))) |
| 118 | 118 | ||
| 119 | (defmacro lread-tests--with-temp-file (file-name-var &rest body) | ||
| 120 | (declare (indent 1)) | ||
| 121 | (cl-check-type file-name-var symbol) | ||
| 122 | `(let ((,file-name-var (make-temp-file "emacs"))) | ||
| 123 | (unwind-protect | ||
| 124 | (progn ,@body) | ||
| 125 | (delete-file ,file-name-var)))) | ||
| 126 | |||
| 127 | (defun lread-tests--last-message () | ||
| 128 | (with-current-buffer "*Messages*" | ||
| 129 | (save-excursion | ||
| 130 | (goto-char (point-max)) | ||
| 131 | (skip-chars-backward "\n") | ||
| 132 | (buffer-substring (line-beginning-position) (point))))) | ||
| 133 | |||
| 134 | (ert-deftest lread-tests--unescaped-char-literals () | ||
| 135 | "Check that loading warns about unescaped character | ||
| 136 | literals (Bug#20852)." | ||
| 137 | (lread-tests--with-temp-file file-name | ||
| 138 | (write-region "?) ?( ?; ?\" ?[ ?]" nil file-name) | ||
| 139 | (should (equal (load file-name nil :nomessage :nosuffix) t)) | ||
| 140 | (should (equal (lread-tests--last-message) | ||
| 141 | (concat (format-message "Loading `%s': " file-name) | ||
| 142 | "unescaped character literals " | ||
| 143 | "\", (, ), ;, [, ] detected!"))))) | ||
| 144 | |||
| 119 | ;;; lread-tests.el ends here | 145 | ;;; lread-tests.el ends here |