aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Malabarba2015-11-04 12:54:53 +0000
committerArtur Malabarba2015-11-04 12:56:25 +0000
commit8e843831eaf271801836b7a3e4dd3b4fb0bb72b8 (patch)
treeee0c22b58dae03ad9c509f301e6a86f844a1a213
parent587b2328377c32950a7ccf89f7c0b7d95db873af (diff)
downloademacs-8e843831eaf271801836b7a3e4dd3b4fb0bb72b8.tar.gz
emacs-8e843831eaf271801836b7a3e4dd3b4fb0bb72b8.zip
* lisp/subr.el (when): Use `macroexp-progn'
* test/automated/subr-tests.el (subr-test-when): New test
-rw-r--r--lisp/subr.el2
-rw-r--r--test/automated/subr-tests.el14
2 files changed, 15 insertions, 1 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index ea926ae1475..91647a67648 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -179,7 +179,7 @@ value of last one, or nil if there are none.
179 179
180\(fn COND BODY...)" 180\(fn COND BODY...)"
181 (declare (indent 1) (debug t)) 181 (declare (indent 1) (debug t))
182 (list 'if cond (cons 'progn body))) 182 (list 'if cond (macroexp-progn body)))
183 183
184(defmacro unless (cond &rest body) 184(defmacro unless (cond &rest body)
185 "If COND yields nil, do BODY, else return nil. 185 "If COND yields nil, do BODY, else return nil.
diff --git a/test/automated/subr-tests.el b/test/automated/subr-tests.el
index 28a423f5ee8..85d5d112d9e 100644
--- a/test/automated/subr-tests.el
+++ b/test/automated/subr-tests.el
@@ -82,5 +82,19 @@
82 (should (string-greaterp 'acb 'abc)) 82 (should (string-greaterp 'acb 'abc))
83 (should (string-greaterp "acb" 'abc))) 83 (should (string-greaterp "acb" 'abc)))
84 84
85(ert-deftest subr-test-when ()
86 (should (equal (when t 1) 1))
87 (should (equal (when t 2) 2))
88 (should (equal (when nil 1) nil))
89 (should (equal (when nil 2) nil))
90 (should (equal (when t 'x 1) 1))
91 (should (equal (when t 'x 2) 2))
92 (should (equal (when nil 'x 1) nil))
93 (should (equal (when nil 'x 2) nil))
94 (should (equal (macroexpand-all '(when a b))
95 '(if a b)))
96 (should (equal (macroexpand-all '(when a b c d))
97 '(if a (progn b c d)))))
98
85(provide 'subr-tests) 99(provide 'subr-tests)
86;;; subr-tests.el ends here 100;;; subr-tests.el ends here