aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
Diffstat (limited to 'test/src')
-rw-r--r--test/src/lread-tests.el26
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
136literals (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