Rack  Unit Abbrevs
1 API Functions
check-true*
check-false*
check-apply*
check-exn*
2 Library Functions
syntax->location
procedure
exn-predicate
3 Other Testing Libraries
8.12

RackUnit Abbrevs🔗ℹ

 (require rackunit-abbrevs) package: rackunit-abbrevs

For writing multiple unit tests on a single function. The macros here repeatedly apply a standard RackUnit assertion on a sequence of argument (and result) pairs.

Test failures are reported at the unit test, not at the call to one of our check- macros.

1 API Functions🔗ℹ

syntax

(check-true* f [arg* ...] ...)

Apply f to each sequence of arguments arg* and assert check-true on each result.

Examples:
> (check-true* (lambda (x y #:z [z 0]) (= (+ x y z) 3))
   [3 0]
   [1 2]
   [1 1 #:z 1])
> (check-true* integer?
    ["hello"])

--------------------

FAILURE

location:   eval:3:0

name:       check-true

params:     '(#f)

--------------------

syntax

(check-false* f [arg* ...] ...)

Apply f to each sequence of arguments arg* and assert check-false on each result.

Examples:
> (check-false* string?
   [1]
   ['lemons])
> (check-false* =
   [2 2])

--------------------

FAILURE

location:   eval:5:0

name:       check-false

params:     '(#t)

--------------------

syntax

(check-apply* f [arg* ... (~or != !=> == => ==>) result] ...)

Apply f to each sequence of arguments arg* and compare to result using equal?. When == or => or ==> is used as a delimiter, calls (check-equal? (f arg* ...) result). Otherwise, calls (check-not-equal? (f arg* ...) result).

Example:
> (check-apply* map
   [add1 '(1 2 3) == '(2 3 4)]
   [append '((c)) '((a)) '((t)) != '((d o g))])

syntax

(check-exn* exn-predicate f [arg* ...] ...)

Apply f to the arguments arg* and assert (check-exn exn-predicate (lambda () (f arg*))) for each.

Examples:
> (check-exn* exn:fail:contract? vector-ref
   [0 #'()]
   ["hi"])
> (check-exn* #rx"\\+: contract violation" +
   [0 #\0 'O]
   ['() '()])

2 Library Functions🔗ℹ

 (require rackunit-abbrevs/error-reporting)
  package: rackunit-abbrevs

These functions are internal to the library but may be useful elsewhere.

procedure

(syntax->location stx)

  (list/c any/c (or/c number? #f) (or/c number? #f) (or/c number? #f) (or/c number? #f))
  stx : syntax?

syntax

procedure

Syntax class used to rule out patterns that are definitely not procedures.

syntax

exn-predicate

Syntax class used to rule out patterns that are definitely not predicates or regular expressions.

3 Other Testing Libraries🔗ℹ