From: Strigoides Date: Fri, 26 Apr 2013 12:49:02 +0000 (+1200) Subject: Fix COND for clauses with length 1 X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=e661ad72cae4e63bcc431986843ce76121d5773a;p=jscl.git Fix COND for clauses with length 1 (COND (1)) should return 1 --- diff --git a/src/boot.lisp b/src/boot.lisp index 40ae705..d30fb79 100644 --- a/src/boot.lisp +++ b/src/boot.lisp @@ -215,10 +215,12 @@ (if (null clausules) nil (if (eq (caar clausules) t) - `(progn ,@(cdar clausules)) - `(if ,(caar clausules) - (progn ,@(cdar clausules)) - (cond ,@(cdr clausules)))))) + `(progn ,@(cdar clausules)) + `(if ,(caar clausules) + ,(if (null (cdar clausules)) + (caar clausules) + `(progn ,@(cdar clausules))) + (cond ,@(cdr clausules)))))) (defmacro case (form &rest clausules) (let ((!form (gensym))) diff --git a/tests/conditionals.lisp b/tests/conditionals.lisp index 9a73dc5..693fbba 100644 --- a/tests/conditionals.lisp +++ b/tests/conditionals.lisp @@ -8,6 +8,7 @@ ; COND (test (eql nil (cond))) +(test (= 1 (cond (1)))) (test (= 2 (cond (1 2)))) (test (= 3 (cond (nil 1) (2 3)))) (test (eql nil (cond (nil 1) (nil 2))))