fukamachi / prove

Yet another unit testing framework for Common Lisp
218 stars 23 forks source link

ok evals test twice #19

Closed deadtrickster closed 8 years ago

deadtrickster commented 9 years ago
(is  (print "1") "1")

"1" Q
  ✓ "1" is expected to be "1" 
T
#<PASSED-TEST-REPORT RESULT: T, GOT: "1", EXPECTED: "1">
TEST> (ok  (print "1") )

"1" 
"1" 
  ✓ "1" is expected to be T 
T
#<PASSED-TEST-REPORT RESULT: T, GOT: "1", EXPECTED: T>
PuercoPop commented 9 years ago

Isn't removing the second evaluation the wrong solution? Including test in the wrapping once-only of the ok macro would be a better fix.

(defmacro ok (test &optional desc)
  (with-gensyms (duration result)
    (once-only (test desc)
      `(with-catching-errors (:expected T :description ,desc)
         (with-duration ((,duration ,result) ,test)
           (test ,result t ,desc
                 :duration ,duration
                 :test-fn (lambda (x y)
                            (eq (not (null x)) y))
                 :got-form ,test))))))
deadtrickster commented 9 years ago

well, ok is basically is with expected hard set to T AFAIK.