lundi 1 février 2016

Rackunit: in-depth check of exception type

In Rackunit, I know how to assert that an exception is thrown:

#lang racket

(module+ test
  (require rackunit)
  (check-exn exn:fail:contract? (lambda () (3 + 4))))

However, I cannot find a way to assert something more specific. Looking at the exception hierarchy in Racket, exn:fail:contract could mean a number of things: a wrong arity, a division by zero ...

I would like to assert in the test that this particular exception is one that reads:

; application: not a procedure;
;  expected a procedure that can be applied to arguments

in its printed message. How do you accomplish this?

Aucun commentaire:

Enregistrer un commentaire