Skip to content

Commit 15bc560

Browse files
committed
Treat exceptions thrown by arguments to check as test failures, without changing function behavior
1 parent 5fc1ec7 commit 15bc560

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

rackunit-lib/rackunit/private/check.rkt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
(with-default-check-info* infos
105105
(λ () ((current-check-around) (λ () body ... (void))))))
106106
'pub)))
107+
107108

108109
(define-simple-macro (define-check (name:id formal:id ...) body:expr ...)
109110
(begin
@@ -112,9 +113,15 @@
112113
(with-syntax ([loc (datum->syntax #f 'loc stx)])
113114
(syntax-parse stx
114115
[(chk . args)
115-
#'((check-impl #:location (syntax->location #'loc)
116-
#:expression '(chk . args))
117-
. args)]
116+
#'(let ([location (syntax->location #'loc)])
117+
(with-default-check-info*
118+
(list (make-check-location location)
119+
(make-check-expression '(chk . args)))
120+
(λ ()
121+
((current-check-around)
122+
(λ () ((check-impl #:location location
123+
#:expression '(chk . args))
124+
. args))))))]
118125
[chk:id
119126
#'(check-impl #:location (syntax->location #'loc)
120127
#:expression 'chk)])))))

rackunit-lib/rackunit/private/format.rkt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@
121121
(display-raised-message e)]
122122
[else
123123
(display-raised-summary "ERROR" e)
124+
(display-check-info-stack (current-check-info)
125+
#:verbose? verbose?)
124126
(display-raised-message e)])
125127
(display-delimiter)))
126128

0 commit comments

Comments
 (0)