Tuesday, July 7, 2009

Test Driven Development with PocketScheme

During the last few days, I've been feverishly pounding out more and more Scheme code, reading a bunch of online documentation and generally staying up until the wee hours of the morning learning more about the rich history and power of Scheme.

Days -> spent looking for a job and packing/sorting/etc
Nights -> Scheme both using PLT and PocketScheme on my ipaq.

However, since I spent the last year in the middle of a programming culture where the first thing one was to do was develop a test for the function you wanted to write, I began to feel a little uneasy about my code until I figured out what it was: I had no unit testing ability.

So, I wrote a small little function called "assert" and it goes like this:
(define (assert test result)
(if (equal? test result)
(display ".")
(display "F")
)
)
which then has a unit test for the list-join function described above as:

(assert (list-join (list 1 2 3) #\,) "1,2,3")
While I was waiting at the doctor's office, I coded up a half dozen tests for my little framework and it wasn't until I googled "unit testing Scheme" that I found this gem: http://www.neilvandyke.org/testeez/ which is Unit Testing for R5RS.

Ah well.

No comments:

Post a Comment