]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/subr.el (when): Use `macroexp-progn'
authorArtur Malabarba <bruce.connor.am@gmail.com>
Wed, 4 Nov 2015 12:54:53 +0000 (12:54 +0000)
committerArtur Malabarba <bruce.connor.am@gmail.com>
Wed, 4 Nov 2015 12:56:25 +0000 (12:56 +0000)
* test/automated/subr-tests.el (subr-test-when): New test

lisp/subr.el
test/automated/subr-tests.el

index ea926ae14751dfe86757c9cc877693db4d8e5f43..91647a67648b096d25ee63c8fa9df3a58dfce1d7 100644 (file)
@@ -179,7 +179,7 @@ value of last one, or nil if there are none.
 
 \(fn COND BODY...)"
   (declare (indent 1) (debug t))
-  (list 'if cond (cons 'progn body)))
+  (list 'if cond (macroexp-progn body)))
 
 (defmacro unless (cond &rest body)
   "If COND yields nil, do BODY, else return nil.
index 28a423f5ee8aa9071c1c366982698d1e682ef0e2..85d5d112d9e80dc6bac80794cf65f946cfea2aac 100644 (file)
   (should (string-greaterp 'acb 'abc))
   (should (string-greaterp "acb" 'abc)))
 
+(ert-deftest subr-test-when ()
+  (should (equal (when t 1) 1))
+  (should (equal (when t 2) 2))
+  (should (equal (when nil 1) nil))
+  (should (equal (when nil 2) nil))
+  (should (equal (when t 'x 1) 1))
+  (should (equal (when t 'x 2) 2))
+  (should (equal (when nil 'x 1) nil))
+  (should (equal (when nil 'x 2) nil))
+  (should (equal (macroexpand-all '(when a b))
+                 '(if a b)))
+  (should (equal (macroexpand-all '(when a b c d))
+                 '(if a (progn b c d)))))
+
 (provide 'subr-tests)
 ;;; subr-tests.el ends here