From 325262d82eb9620b042e4c2bad38eb5dd47c03ef Mon Sep 17 00:00:00 2001 From: Marco Baringer Date: Tue, 26 Jun 2007 12:54:43 +0200 Subject: [PATCH] Avoid dobule evaluation of IS-FALSE's argument --- src/check.lisp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/check.lisp b/src/check.lisp index c2f4ee7..cdf57fd 100644 --- a/src/check.lisp +++ b/src/check.lisp @@ -229,13 +229,16 @@ REASON-ARGS is provided, is generated based on the form of TEST: failure otherwise. Like IS-TRUE, and unlike IS, IS-FALSE does not inspect CONDITION to determine what reason to give it case of test failure" - `(if ,condition - (process-failure - :reason ,(if reason-args - `(format nil ,@reason-args) - `(format nil "~S returned a true value" ',condition)) - :test-expr ',condition) - (add-result 'test-passed :test-expr ',condition))) + + (with-unique-names (value) + `(let ((,value ,condition)) + (if ,value + (process-failure + :reason ,(if reason-args + `(format nil ,@reason-args) + `(format nil "~S returned the value ~S, which is true" ',condition ,value )) + :test-expr ',condition) + (add-result 'test-passed :test-expr ',condition))))) (defmacro signals (condition-spec &body body) -- 1.7.10.4