Skip to content

Commit

Permalink
Rename check-error to check-fail/error
Browse files Browse the repository at this point in the history
  • Loading branch information
jackfirth committed Sep 2, 2017
1 parent 0c04a16 commit 32acc1d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 36 deletions.
12 changes: 6 additions & 6 deletions rackunit-doc/rackunit/scribblings/check.scrbl
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ expected or that checks add certain information to the check information stack.
instead checks that the regexp matches the check failure exception's message.
Note that a check failure exception's message is the message given to
@racket[fail-check], not the optional @racket[message] argument that all checks
accept. See also @racket[check-exn] and @racket[check-error].
accept. See also @racket[check-exn] and @racket[check-fail/error].

@(examples
#:eval rackunit-eval
Expand Down Expand Up @@ -518,10 +518,10 @@ expected or that checks add certain information to the check information stack.

@history[#:added "1.8"]}

@defproc[(check-error [fail-exn-predicate
(or/c (-> exn:test:check? any/c) regexp?)]
[thunk (-> any)]
[message string? ""])
@defproc[(check-fail/error [fail-exn-predicate
(or/c (-> exn:test:check? any/c) regexp?)]
[thunk (-> any)]
[message string? ""])
void?]{
Checks that @racket[thunk] evaluates a check that raises an error value instead
of passing or failing, and checks that the raised value satisfies
Expand All @@ -536,7 +536,7 @@ expected or that checks add certain information to the check information stack.
(define-check (error-check)
(raise (make-exn:fail "Kaboom!!!" (current-continuation-marks)))
(fail-check "Doesn't get here"))
(check-error #rx"boom" error-check))
(check-fail/error #rx"boom" error-check))

@history[#:added "1.8"]}

Expand Down
8 changes: 4 additions & 4 deletions rackunit-lib/rackunit/private/meta.rkt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#lang racket/base

(provide check-error
(provide check-fail/error
check-fail
check-fail*
check-fail/info)
Expand Down Expand Up @@ -57,9 +57,9 @@
(assert-failure failure)
(assert-check-failure failure))

(define-check (check-error pred-or-msg chk-thnk)
(contract-pred-or-msg! 'check-error pred-or-msg)
(contract-thunk! 'check-error chk-thnk)
(define-check (check-fail/error pred-or-msg chk-thnk)
(contract-pred-or-msg! 'check-fail/error pred-or-msg)
(contract-thunk! 'check-fail/error chk-thnk)
(define failure (check-raise-value chk-thnk))
(with-expected pred-or-msg
(assert-failure failure)
Expand Down
52 changes: 26 additions & 26 deletions rackunit-test/tests/rackunit/meta-test.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
(check-fail #rx"No check failure occurred"
(λ () (check-fail/info foo-info void)))
(check-fail #rx"No check failure occurred"
(λ () (check-error (λ (_) #t) void))))
(λ () (check-fail/error (λ (_) #t) void))))

(test-case "non-error meta checks fail on non-failure raised values"
(check-fail #rx"A value other than a check failure was raised"
Expand Down Expand Up @@ -76,41 +76,41 @@
(check-fail/info (make-check-actual (make-check-info 'foo 'bar))
(λ () (check-fail/info foo-info fail/foo-bar))))

(test-case "check-error asserts check raises non-failure error matching predicate or regexp"
(test-case "check-fail/error asserts check raises non-failure error matching predicate or regexp"
(define-check (raise-foo) (raise 'foo))
(check-error (λ (v) (equal? v 'foo)) raise-foo)
(check-fail/error (λ (v) (equal? v 'foo)) raise-foo)
(check-fail #rx"Wrong error raised"
(λ () (check-error (λ (v) (equal? v 'bar)) raise-foo)))
(λ () (check-fail/error (λ (v) (equal? v 'bar)) raise-foo)))
(define-check (raise-exn)
(raise (make-exn "Message!" (current-continuation-marks))))
(check-error #rx"sage" raise-exn)
(check-fail/error #rx"sage" raise-exn)
(check-fail #rx"Wrong error raised"
(λ () (check-error #rx"notinmessage" raise-exn)))
(λ () (check-fail/error #rx"notinmessage" raise-exn)))
(check-fail #rx"Wrong error raised"
(λ () (check-error #rx"foo" raise-foo)))
(λ () (check-fail/error #rx"foo" raise-foo)))
(check-fail #rx"Wrong error raised"
(λ () (check-error (λ (_) #t) fail))))
(λ () (check-fail/error (λ (_) #t) fail))))

(test-case "meta checks raise contract errors on invalid arguments"
(define ((contract-exn/source source) v)
(and (exn:fail:contract? v)
(regexp-match? (regexp source) (exn-message v))))
(define (not-a-pred v extra) #t)
(check-error (contract-exn/source "check-fail")
(λ () (check-fail 'not-pred-or-regexp fail)))
(check-error (contract-exn/source "check-fail")
(λ () (check-fail #rx"foo" 'not-a-thunk)))
(check-error (contract-exn/source "check-fail")
(λ () (check-fail not-a-pred fail)))
(check-error (contract-exn/source "check-fail*")
(λ () (check-fail* 'not-a-thunk)))
(check-error (contract-exn/source "check-fail/info")
(λ () (check-fail/info 'not-info fail)))
(check-error (contract-exn/source "check-fail/info")
(λ () (check-fail/info foo-info 'not-a-thunk)))
(check-error (contract-exn/source "check-error")
(λ () (check-error 'not-pred-or-regexp fail)))
(check-error (contract-exn/source "check-error")
(λ () (check-error #rx"foo" 'not-a-thunk)))
(check-error (contract-exn/source "check-error")
(λ () (check-error not-a-pred fail)))))
(check-fail/error (contract-exn/source "check-fail")
(λ () (check-fail 'not-pred-or-regexp fail)))
(check-fail/error (contract-exn/source "check-fail")
(λ () (check-fail #rx"foo" 'not-a-thunk)))
(check-fail/error (contract-exn/source "check-fail")
(λ () (check-fail not-a-pred fail)))
(check-fail/error (contract-exn/source "check-fail*")
(λ () (check-fail* 'not-a-thunk)))
(check-fail/error (contract-exn/source "check-fail/info")
(λ () (check-fail/info 'not-info fail)))
(check-fail/error (contract-exn/source "check-fail/info")
(λ () (check-fail/info foo-info 'not-a-thunk)))
(check-fail/error (contract-exn/source "check-fail/error")
(λ () (check-fail/error 'not-pred-or-regexp fail)))
(check-fail/error (contract-exn/source "check-fail/error")
(λ () (check-fail/error #rx"foo" 'not-a-thunk)))
(check-fail/error (contract-exn/source "check-fail/error")
(λ () (check-fail/error not-a-pred fail)))))

0 comments on commit 32acc1d

Please sign in to comment.