From 32acc1d08883de144c6add716ff96ed495a1278d Mon Sep 17 00:00:00 2001 From: Jack Firth Date: Thu, 13 Jul 2017 00:03:36 -0700 Subject: [PATCH] Rename check-error to check-fail/error --- rackunit-doc/rackunit/scribblings/check.scrbl | 12 ++--- rackunit-lib/rackunit/private/meta.rkt | 8 +-- rackunit-test/tests/rackunit/meta-test.rkt | 52 +++++++++---------- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/rackunit-doc/rackunit/scribblings/check.scrbl b/rackunit-doc/rackunit/scribblings/check.scrbl index 6b784e4..ff54f09 100644 --- a/rackunit-doc/rackunit/scribblings/check.scrbl +++ b/rackunit-doc/rackunit/scribblings/check.scrbl @@ -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 @@ -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 @@ -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"]} diff --git a/rackunit-lib/rackunit/private/meta.rkt b/rackunit-lib/rackunit/private/meta.rkt index 7da102a..5c1de91 100644 --- a/rackunit-lib/rackunit/private/meta.rkt +++ b/rackunit-lib/rackunit/private/meta.rkt @@ -1,6 +1,6 @@ #lang racket/base -(provide check-error +(provide check-fail/error check-fail check-fail* check-fail/info) @@ -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) diff --git a/rackunit-test/tests/rackunit/meta-test.rkt b/rackunit-test/tests/rackunit/meta-test.rkt index 91e981d..eb0e6f3 100644 --- a/rackunit-test/tests/rackunit/meta-test.rkt +++ b/rackunit-test/tests/rackunit/meta-test.rkt @@ -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" @@ -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)))))