[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Built in Tests
X-Authentication-Warning: fast.cs.utah.edu: majordom set sender to owner-plt-scheme@flux.cs.utah.edu using -f
From: Greg Pettyjohn <GregP@bsquare.com>
Date: Thu, 23 Mar 2000 17:27:35 -0800
Content-Type: text/plain;
charset="iso-8859-1"
Sender: owner-plt-scheme@fast.cs.utah.edu
Precedence: bulk
I've noticed and heard mention of test code that you folks
(the PLT crew) use in your source code.
In particular it appears that you have tests for each of the routines
accompanying the routines in the actual source. These tests are
commented out and you have an automated process in place that sweeps
through the source and tests each routine.
;; ---
Dreams:
It's not automatic (yet), though I'd like it to be.
Ideally we would like top-level definitions to be in
cells (say like Mathematica) and each cell would come
with fields that you can turn on and off: comments,
types, tests, etc. For now, none of this exists.
;; ---
What works:
For each file, I add the tests for each function to the
bottom of my files like this:
#| TESTS:
--------------------------------------------------------------
(define the-function max)
(define (tester label expected-value . args)
(with-handler ((exn:user? (lambda (x) (printf "bad test ~s: ~n" label))))
(= expected-values (apply the-function args))))
(define (error-tester label . args)
(with-handler ((exn:user? (lambda (x) #t)))
(apply the-function args)
(printf "bad test ~s: ~n" label)))
(tester 1 3 1 2 3 2 1)
(error-tester 'e2) ; because max uses non-empty lists
|#
When I change something, I move the closing |# to the end of the ---
line and execute. Of course, I may have to change my tests.
-- matthias