views:

22

answers:

1

Hi Everyone,

I'm currently working in some racket programs, specifically in the PLAI's language of the Programming Languages: Application and Interpretation Book, and there is a function called test, i was wondering how to test the error throwing in racket? Does anyone knows how to do this?

Greetings

(I'm not a native english speaker, i hope this question can be understand)

+1  A: 

There is test/exn that you can use to test error messages, for example:

(test/exn (error "foo") "foo")

but note that the docs say that it can test only exceptions that were explicitly raised by your code. The idea is that your code should check for errors and raise them, otherwise you have a bug.

(For testing of "real" racket code, see rackunit.

Eli Barzilay