diff options
author | Philipp Stephani <phst@google.com> | 2015-06-30 22:38:35 +0200 |
---|---|---|
committer | Philipp Stephani <phst@google.com> | 2017-05-01 20:39:10 +0200 |
commit | c2bbdc3316487e34eba1470dd059c0c290431e00 (patch) | |
tree | bed5315e69d89c99c62be4a78e8f26d799643f70 /test/lisp/emacs-lisp | |
parent | b72e36047c9a5d46b02e12252e0fc640b6839903 (diff) | |
download | emacs-c2bbdc3316487e34eba1470dd059c0c290431e00.tar.gz emacs-c2bbdc3316487e34eba1470dd059c0c290431e00.tar.bz2 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/lisp/emacs-lisp')
-rw-r--r-- | test/lisp/emacs-lisp/bytecomp-tests.el | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el index e8feec31d26..3624904753c 100644 --- a/test/lisp/emacs-lisp/bytecomp-tests.el +++ b/test/lisp/emacs-lisp/bytecomp-tests.el @@ -506,6 +506,29 @@ bytecompiled code, and their results compared.") (dolist (pat bytecomp-lexbind-tests) (should (bytecomp-lexbind-check-1 pat)))) +(defmacro bytecomp-tests--with-temp-file (file-name-var &rest body) + (declare (indent 1)) + (cl-check-type file-name-var symbol) + `(let ((,file-name-var (make-temp-file "emacs"))) + (unwind-protect + (progn ,@body) + (delete-file ,file-name-var)))) + +(ert-deftest bytecomp-tests--unescaped-char-literals () + "Check that byte compiling warns about unescaped character +literals (Bug#20852)." + (should (boundp 'lread--unescaped-character-literals)) + (bytecomp-tests--with-temp-file source + (write-region "(list ?) ?( ?; ?\" ?[ ?])" nil source) + (bytecomp-tests--with-temp-file destination + (let* ((byte-compile-dest-file-function (lambda (_) destination)) + (byte-compile-error-on-warn t) + (byte-compile-debug t) + (err (should-error (byte-compile-file source)))) + (should (equal (cdr err) + (list (concat "unescaped character literals " + "\", (, ), ;, [, ] detected!")))))))) + ;; Local Variables: ;; no-byte-compile: t ;; End: |