Skip to content

Commit ce0ba9f

Browse files
authored
Treat exceptions thrown by arguments to check as test failures, without changing function behavior (#109)
* Treat exceptions thrown by arguments to check as test failures, without changing function behavior * Update standalone tests for errors
1 parent 5117320 commit ce0ba9f

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

rackunit-lib/rackunit/private/check.rkt

Lines changed: 11 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,16 @@
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-name 'name)
119+
(make-check-location location)
120+
(make-check-expression '(chk . args)))
121+
(λ ()
122+
((current-check-around)
123+
(λ () ((check-impl #:location location
124+
#:expression '(chk . args))
125+
. args))))))]
118126
[chk:id
119127
#'(check-impl #:location (syntax->location #'loc)
120128
#: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

rackunit-test/tests/rackunit/standalone.rkt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
#"\
4242
--------------------
4343
ERROR
44+
name: check-pred
45+
location: standalone-check-test.rkt:44:0
4446
4547
Outta here!
4648
--------------------
@@ -59,12 +61,14 @@ message: 0.0
5961
--------------------
6062
ERROR
6163
64+
6265
First Outta here!
6366
--------------------
6467
--------------------
6568
error
6669
ERROR
6770
71+
6872
Second Outta here!
6973
--------------------
7074
--------------------

0 commit comments

Comments
 (0)