Commit 8e843831 authored by Artur Malabarba's avatar Artur Malabarba
Browse files

* lisp/subr.el (when): Use `macroexp-progn'

* test/automated/subr-tests.el (subr-test-when): New test
parent 587b2328
......@@ -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.
......
......@@ -82,5 +82,19 @@
(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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment