[racket-dev] Testing mode
20 minutes ago, Jay McCarthy wrote:
> I was worried about situations where you had some code that had
> module toplevel code that starts up a long running process that
> shouldn't be run in test mode, so I wanted to cordon off that. I
> wasn't imagining anything as complicated as what Neil or Eli seem to
> want. (Seems like overkill to me.)
(Makes me happy then, that what I view as a simplification is good
enough to be considered an overkill...)
> I dislike Eli's proposal because I don't think it gets tests close
> to their functions with low syntactic overhead. For example...
>
> (define (f x) ...)
> (check-equal? (f 5) 10)
>
> ; 200 lines of more stuff
>
> (define (g x) ...)
> (check-equal? (g 7) 14)
> [...]
Since you want `check-equal?' etc to be macros anyway, doing this is
easy. A cheap way would be along the lines of:
(define-syntax (with-testing e ...)
(set! MAIN (let ([old MAIN]) (lambda _ (old) e ...))))
A more sophisticated thing would be something that scans the module.
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://barzilay.org/ Maze is Life!