-
-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Labels
Description
I have a lot of tests that look like this:
(test-case "customer-order-sales-tax should calculate tax correctly"
(define order (customer-order #:price 10.00))
(check-equal? (customer-order-sales-tax order) 0.50))
When this fails, I'll see an error message like this:
FAILURE
customer-order-sales-tax should calculate tax correctly
actual: 0.80
expected: 0.50
In DrRacket this isn't so bad since the source location info lets me jump to the failing check and see that order
is (customer-order #:price 10.00)
. But when running tests from the terminal, the failure message doesn't give very much information.
I propose changing check-equal?
(and perhaps other checks) to recognize when the actual
expression is a "simple" function call and add check infos for the arguments automatically. So a test like this:
(test-case "f should calculate its result correctly"
(define x 5)
(define y 10)
(define z 20)
(check-equal? (f x y z) 42))
Should produce failures like this:
FAILURE
f should calculate its result correctly
x: 5
y: 10
z: 20
actual: -42
expected: 42
That is, for any check of the form (check-equal? (function:id arg:id ...) expected:expr)
, each arg
value should be added to the check info stack under the name 'arg
.
samdphillips