aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDaniel Colascione2014-04-21 02:34:21 -0700
committerDaniel Colascione2014-04-21 02:34:21 -0700
commit985c035f2d4cf326a816fe463c400be96e358be2 (patch)
tree8db28fe4100f4e5988824dcc956fd6a7088e98ae /test
parent0c8d94555ce550d87afd6293bf5d17e864c13864 (diff)
downloademacs-985c035f2d4cf326a816fe463c400be96e358be2.tar.gz
emacs-985c035f2d4cf326a816fe463c400be96e358be2.zip
Correctly treat progn contents as toplevel forms when byte compiling
Diffstat (limited to 'test')
-rw-r--r--test/ChangeLog7
-rw-r--r--test/automated/bytecomp-tests.el50
2 files changed, 57 insertions, 0 deletions
diff --git a/test/ChangeLog b/test/ChangeLog
index 942455ad22b..4003a24bc6b 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,5 +1,12 @@
12014-04-21 Daniel Colascione <dancol@dancol.org> 12014-04-21 Daniel Colascione <dancol@dancol.org>
2 2
3 * automated/bytecomp-tests.el (test-byte-comp-compile-and-load):
4 New function.
5 (test-byte-comp-macro-expansion)
6 (test-byte-comp-macro-expansion-eval-and-compile)
7 (test-byte-comp-macro-expansion-eval-when-compile)
8 (test-byte-comp-macro-expand-lexical-override): New tests.
9
3 * automated/cl-lib.el (cl-loop-destructuring-with): New test. 10 * automated/cl-lib.el (cl-loop-destructuring-with): New test.
4 (cl-the): Fix cl-the test. 11 (cl-the): Fix cl-the test.
5 12
diff --git a/test/automated/bytecomp-tests.el b/test/automated/bytecomp-tests.el
index 0a9a301dd0d..e61c7c3a41d 100644
--- a/test/automated/bytecomp-tests.el
+++ b/test/automated/bytecomp-tests.el
@@ -305,6 +305,56 @@ Subtests signal errors if something goes wrong."
305 'face fail-face))) 305 'face fail-face)))
306 (insert "\n")))) 306 (insert "\n"))))
307 307
308(defun test-byte-comp-compile-and-load (&rest forms)
309 (let ((elfile nil)
310 (elcfile nil))
311 (unwind-protect
312 (progn
313 (setf elfile (make-temp-file "test-bytecomp" nil ".el"))
314 (setf elcfile (make-temp-file "test-bytecomp" nil ".elc"))
315 (with-temp-buffer
316 (dolist (form forms)
317 (print form (current-buffer)))
318 (write-region (point-min) (point-max) elfile))
319 (let ((byte-compile-dest-file elcfile))
320 (byte-compile-file elfile t)))
321 (when elfile (delete-file elfile))
322 (when elcfile (delete-file elcfile)))))
323(put 'test-byte-comp-compile-and-load 'lisp-indent-function 0)
324
325(ert-deftest test-byte-comp-macro-expansion ()
326 (test-byte-comp-compile-and-load
327 '(progn (defmacro abc (arg) 1) (defun def () (abc 2))))
328 (should (equal (funcall 'def) 1)))
329
330(ert-deftest test-byte-comp-macro-expansion-eval-and-compile ()
331 (test-byte-comp-compile-and-load
332 '(eval-and-compile (defmacro abc (arg) -1) (defun def () (abc 2))))
333 (should (equal (funcall 'def) -1)))
334
335(ert-deftest test-byte-comp-macro-expansion-eval-when-compile ()
336 ;; Make sure we interpret eval-when-compile forms properly. CLISP
337 ;; and SBCL interpreter eval-when-compile (well, the CL equivalent)
338 ;; in the same way.
339 (test-byte-comp-compile-and-load
340 '(eval-when-compile
341 (defmacro abc (arg) -10)
342 (defun abc-1 () (abc 2)))
343 '(defmacro abc-2 () (abc-1))
344 '(defun def () (abc-2)))
345 (should (equal (funcall 'def) -10)))
346
347(ert-deftest test-byte-comp-macro-expand-lexical-override ()
348 ;; Intuitively, one might expect the defmacro to override the
349 ;; macrolet since macrolet's is explicitly called out as being
350 ;; equivalent to toplevel, but CLISP and SBCL both evaluate the form
351 ;; this way, so we should too.
352 (test-byte-comp-compile-and-load
353 '(require 'cl-lib)
354 '(cl-macrolet ((m () 4))
355 (defmacro m () 5)
356 (defun def () (m))))
357 (should (equal (funcall 'def) 4)))
308 358
309;; Local Variables: 359;; Local Variables:
310;; no-byte-compile: t 360;; no-byte-compile: t