Should failures of "assert" use `~e` to control printout length?

Here's a program:

#lang typed/racket

(assert (make-list 10000 "ouch")
        integer?)

The assertion fails... but then it takes 10 seconds or so to print out the error message. Should this error message be abbreviated? Is it as simple as using ~e in a format string somewhere?

1 Like

Yes, that sounds like the right thing to do. The implementation of assert should be easy to find with a right click.

On my way to fixing this, I ran into two more questions.

  1. Should I add a test case, checking (say) that the error message for a particular assert is less than some length? Or is that not necessary?

  2. in the following program, the source location of the type checking error is given as the #%module-begin. In other words, the whole file is highlighted. Is this a bug?

#lang typed/racket

(require typed/rackunit)

(check < "hello" 14)

Adding my test case here so I don't forget it...

#lang typed/racket

(require typed/rackunit)

(with-handlers ([exn:fail?
                 (λ ([e : exn])
                   (check < (string-length (exn-message e)) 400)
                   #f)])
  (assert (make-list 10000 "ouch")
          integer?)
  #f)