Compare expected value and the result only once.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
This commit is contained in:
OGINO Masanori 2015-07-21 15:12:43 +09:00
parent 24b4cafe65
commit 1455c7d4a5
1 changed files with 23 additions and 24 deletions

View File

@ -39,30 +39,29 @@
(let ((res expr))
(display "case ")
(write counter)
(cond
((equal? res expected)
(display " PASS: ")
(write 'expr)
(display " equals ")
(write expected)
(display "")
(newline)
)
((not (equal? res expected))
(set! failure-counter (+ failure-counter 1))
(let ((out (open-output-string)))
(display " FAIL: " out)
(write 'expr out)
(newline out)
(display " expected " out)
(write expected out)
(display " but got " out)
(write res out)
(display "" out)
(newline out)
(let ((str (get-output-string out)))
(set! fails (cons str fails))
(display str)))))
(if (equal? res expected)
(begin
(display " PASS: ")
(write 'expr)
(display " equals ")
(write expected)
(display "")
(newline))
(begin
(set! failure-counter (+ failure-counter 1))
(let ((out (open-output-string)))
(display " FAIL: " out)
(write 'expr out)
(newline out)
(display " expected " out)
(write expected out)
(display " but got " out)
(write res out)
(display "" out)
(newline out)
(let ((str (get-output-string out)))
(set! fails (cons str fails))
(display str)))))
(set! counter (+ counter 1))))))
(define-syntax test-values