A thread of conversation on the agile-testing yahoo group is speculating on the ability to define a function and its tests "contiguously" to reduce the effort to make the contextual switch between "coding" and "testing".
Here is a simple Scheme macro to approximate the idea...
; The following is a macro that allows you to supply test input and
; test results when you define a function. After the function is
; defined, the tool automatically runs the function on the test input
; and checks to see if it matches the expected result. There are a
; number of enhancements (list of test inputs, define test function,
; etc.) to consider.
(defmacro define-eg (name-result parameter-input . body)
(let ((name (car name-result))
(eg-result (cadr name-result))
(parameters (map (lambda (p) (car p)) parameter-input))
(eg-input (map (lambda (p) (cadr p)) parameter-input)))
`(begin (define (,name ,@parameters)
(equal? ,eg-result (,name ,@eg-input)))))
(define-eg (product-of-sums 108) ((a 5) (b 7) (c 9))
(* (+ a b) c))
> (load "define-eg.scm")
> (define-eg (product-of-sums 108) ((a 5) (b 7) (c 9)) (* (+ a b) c))
> (product-of-sums 5 7 9)
> (define-eg (bad-product-of-sums 108) ((a 5) (b 7) (c 9)) (+ (* a b) c))
> (bad-product-of-sums 5 7 9)