Small changes/fixes to rackunit.
* Add optional message for fail-check. * Correctly shorten column name.
This commit is contained in:
parent
f754624e9a
commit
02b9de16bd
|
@ -419,10 +419,12 @@ if the macro @racket[fail-check] is called in the body of
|
||||||
the check. This allows more flexible checks, and in
|
the check. This allows more flexible checks, and in
|
||||||
particular more flexible reporting options.}
|
particular more flexible reporting options.}
|
||||||
|
|
||||||
@defform[(fail-check)]{
|
@defform*[[(fail-check)
|
||||||
|
(fail-check message-expr)]]{
|
||||||
|
|
||||||
The @racket[fail-check] macro raises an @racket[exn:test:check] with
|
The @racket[fail-check] macro raises an @racket[exn:test:check] with
|
||||||
the contents of the check information stack.
|
the contents of the check information stack. The optional message
|
||||||
|
is used as the exception's message.
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,14 +70,19 @@
|
||||||
|
|
||||||
(define-syntax fail-check
|
(define-syntax fail-check
|
||||||
(syntax-rules ()
|
(syntax-rules ()
|
||||||
((_)
|
((_ message*)
|
||||||
(let ([marks (current-continuation-marks)])
|
(let ([message message*]
|
||||||
|
[marks (current-continuation-marks)])
|
||||||
|
(unless (string? message)
|
||||||
|
(raise-type-error 'fail-check "string" message))
|
||||||
(test-log! #f)
|
(test-log! #f)
|
||||||
(raise
|
(raise
|
||||||
(make-exn:test:check
|
(make-exn:test:check
|
||||||
"Check failure"
|
message
|
||||||
marks
|
marks
|
||||||
(check-info-stack marks)))))))
|
(check-info-stack marks)))))
|
||||||
|
((_)
|
||||||
|
(fail-check "Check failure"))))
|
||||||
|
|
||||||
(define-syntax fail-internal
|
(define-syntax fail-internal
|
||||||
(syntax-rules ()
|
(syntax-rules ()
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
[(m . < . n)
|
[(m . < . n)
|
||||||
(string-append s (make-string (- n m) #\space))]
|
(string-append s (make-string (- n m) #\space))]
|
||||||
[else
|
[else
|
||||||
(substring s n)]))
|
(substring s 0 n)]))
|
||||||
|
|
||||||
(define (display-check-info-name-value name value [value-printer write])
|
(define (display-check-info-name-value name value [value-printer write])
|
||||||
(display (string-pad-right
|
(display (string-pad-right
|
||||||
|
|
Loading…
Reference in New Issue
Block a user