Skip to content

Treat exceptions thrown by arguments to check as test failures, without changing function behavior #109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions rackunit-lib/rackunit/private/check.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
(with-default-check-info* infos
(λ () ((current-check-around) (λ () body ... (void))))))
'pub)))


(define-simple-macro (define-check (name:id formal:id ...) body:expr ...)
(begin
Expand All @@ -112,9 +113,16 @@
(with-syntax ([loc (datum->syntax #f 'loc stx)])
(syntax-parse stx
[(chk . args)
#'((check-impl #:location (syntax->location #'loc)
#:expression '(chk . args))
. args)]
#'(let ([location (syntax->location #'loc)])
(with-default-check-info*
(list (make-check-name 'name)
(make-check-location location)
(make-check-expression '(chk . args)))
(λ ()
((current-check-around)
(λ () ((check-impl #:location location
#:expression '(chk . args))
. args))))))]
[chk:id
#'(check-impl #:location (syntax->location #'loc)
#:expression 'chk)])))))
Expand Down
2 changes: 2 additions & 0 deletions rackunit-lib/rackunit/private/format.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@
(display-raised-message e)]
[else
(display-raised-summary "ERROR" e)
(display-check-info-stack (current-check-info)
#:verbose? verbose?)
(display-raised-message e)])
(display-delimiter)))

Expand Down
4 changes: 4 additions & 0 deletions rackunit-test/tests/rackunit/standalone.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
#"\
--------------------
ERROR
name: check-pred
location: standalone-check-test.rkt:44:0

Outta here!
--------------------
Expand All @@ -59,12 +61,14 @@ message: 0.0
--------------------
ERROR


First Outta here!
--------------------
--------------------
error
ERROR


Second Outta here!
--------------------
--------------------
Expand Down